Simple Top-Down Physics (air hockey), need help!

So i had an idea for a loader, just a simple top-down view of a puck that you can hit around with your mouse.

The problem? when the objects collide there is no bounce or slide... it just kind of pushes the puck out of the way. The gravity and friction is set to 0. Can anyone see what I might be doing wrong? I played around with the variables but it always seems to give me the same result.

I've been messing around with this for a couple days now, but the effect is always the same 🙁 any help or advice would be greatly appreciated.

EDIT: Even when I bump up the gravity to 9999999999999 it does nothing... the puck body just very slowly moves down.

example:
http://www.entrance4.net/examples/preloader.swf

zip:
http://www.entrance4.net/examples/preloaderExample.zip

source:
Code:
package singulair {
   import flash.display.MovieClip;
   import flash.display.Sprite;
   import flash.display.Loader;
   import flash.display.Stage;
   import flash.events.Event;
   import flash.events.IOErrorEvent;
   import flash.events.ProgressEvent;
   import flash.events.MouseEvent;
   import flash.net.URLLoader;
   import flash.net.URLRequest;
   import flash.utils.Dictionary;
   import flash.geom.Point;
   
   import Box2D.Dynamics.*;
   import Box2D.Collision.*;
   import Box2D.Collision.Shapes.*;
   import Box2D.Common.Math.*;
   import Box2D.Dynamics.Joints.*;
   
   import gs.TweenMax;
   import gs.easing.Strong;
   
   public class Preloader extends MovieClip {
      
      // box2d
      public var m_timestep:Number = 1.0/30.0;
      public var m_iterations:Number = 10.0;
      public var m_world:b2World;
      public var m_dbgSprite:Sprite;
      public var m_phys_scale:Number = 30.0;
      public var collider:b2Body;
      public var puck_body:b2Body;
      public var m_mouseJoint:b2MouseJoint;
      public var dimensions = new Point(950, 550);
      
      public function Preloader():void {
         puck.gotoAndPlay(2);
         TweenMax.from(puck, .6, {alpha:0, blurFilter:{blurX:10, blurY:10}});
         puck.addEventListener("DONE", _puckDynamics);
      }
      
   // PUCK DYNAMICS ////////////////////////////////////
   
      private function _puckDynamics(e:Event):void {
         _initBox2D();
         _currentMouseX = mouseX;
         _currentMouseY = mouseY;
         this.addEventListener(Event.ENTER_FRAME, _loopPuck);
         _puckShape();
         _colliderShape();
      }
      
      private function _initBox2D():void {
         var gravity:b2Vec2 = new b2Vec2(0,0);
         var worldAABB:b2AABB = new b2AABB();
         worldAABB.lowerBound.Set(-1000,-1000);
         worldAABB.upperBound.Set(1000,1000);
         m_world = new b2World(worldAABB,gravity,true);
         SetDebugDraw();
      }
      
      private function _puckShape():void {
         var bodyDef:b2BodyDef = new b2BodyDef();
         bodyDef.position.Set(puck.x,puck.y);
         bodyDef.massData.mass = 0.01;
         bodyDef.allowSleep = false;
         bodyDef.linearDamping = 0.0;
         var circleDef = new b2CircleDef();
         circleDef.radius= 40;
         circleDef.friction = 0.0;
         circleDef.restitution = .9;
         puck_body = m_world.CreateBody(bodyDef);
         puck_body.CreateShape(circleDef);
      }
      
      private function _colliderShape():void {
         var bodyDef:b2BodyDef = new b2BodyDef();
         bodyDef.position.Set(400, 275);
         bodyDef.massData.mass = 1.0;
         bodyDef.angle = 0;
         bodyDef.fixedRotation = true;
         bodyDef.allowSleep = false;
         var circleDef = new b2CircleDef();
         circleDef.radius= 20;
         circleDef.density = 10.0;
         circleDef.friction = 0.0;
         circleDef.restitution = 0.9;
         collider = m_world.CreateBody(bodyDef);
         collider.CreateShape(circleDef);
         var md:b2MouseJointDef = new b2MouseJointDef();
         md.body1 = m_world.GetGroundBody();
         md.body2 = collider;
         md.target.Set(400, 275);
         md.maxForce = 100000;
         md.timeStep = m_timestep;
         m_mouseJoint = m_world.CreateJoint(md) as b2MouseJoint;
         stage.addEventListener(MouseEvent.MOUSE_MOVE, mJoint, false, 0, true);
      }
      
      private function mJoint(e:MouseEvent):void {
         var p2:b2Vec2 = new b2Vec2(mouseX, mouseY);
         m_mouseJoint.SetTarget(p2);
      }
      
      public function SetDebugDraw():void {
         //trace("set debug");
         var m_sprite = new Sprite();
         addChild(m_sprite);
         var dbgDraw:b2DebugDraw = new b2DebugDraw();
         var dbgSprite:Sprite = new Sprite();
         m_sprite.addChild(dbgSprite);
         dbgDraw.m_sprite = m_sprite;
         dbgDraw.m_drawScale = 1;
         dbgDraw.m_fillAlpha = 0.3;
         dbgDraw.m_lineThickness = 1.0;
         dbgDraw.m_drawFlags = b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit;
         m_world.SetDebugDraw(dbgDraw);
      }
      
      public function copyPhysicsToMovieclip(body:b2Body, mc:MovieClip):void {
         var pos:b2Vec2 = body.GetPosition();
         mc.x = pos.x;
         mc.y = pos.y;
      }
      
   // ENTERFRAME ////////////////////////////////////////
      
      private function _loopPuck(e:Event):void {
         //mouseHit.x = mouseX-5;
         //mouseHit.y = mouseY-5;
         m_world.Step(m_timestep,m_iterations);
         if(puck_body) {
            copyPhysicsToMovieclip(puck_body, puck)
         }
      }
   }
}
There were/are a number of problems with this.

First, Box2D is tuned to handle objects in between 0.1 and 10.0 meters/units( I may be off on this since I'm pulling it from memory, check the docs to be sure. ) Hence the reason for the scaling factor that is used in all the examples.
You are setting the debugDraw scaling to 1, and using pixel units to both size and place your bodies. This isn't wrong, but you will experience errors when the simulation is expecting things in the 0.1 to 10.0 scale.

Second, and this is a result of the first, you are hitting the b2_MaxLinearVelocity threshold. In the file that you sent( which I don't have that version of box2D anymore to check against) it was set to 4.0; When I arbitrarily increased it to 400.0 the simulation moved better.

Third, you are manually setting the massData.mass parameter. I've read from posts from Erin that doing so can speed up dynamic body creation, but I don't think this is what you are trying to do here... A safer way to set the mass is to set the density on your shapeDef and then call b2Body::SetMassFromShapes();

IE:
Code:
private function _puckShape():void {
         var bodyDef:b2BodyDef = new b2BodyDef();
         bodyDef.position.Set(puck.x,puck.y);
         //bodyDef.massData.mass = 0.01; <--------- commented this out since its not really needed.
         bodyDef.allowSleep = false;
         bodyDef.linearDamping = 0.0;
         var circleDef:b2CircleDef = new b2CircleDef();
         circleDef.radius = 40;
         circleDef.density = 1.0; <---- added this.
         circleDef.friction = 0.0;
         circleDef.restitution = .9;
         puck_body = m_world.CreateBody(bodyDef);
         puck_body.CreateShape(circleDef);
         puck_body.SetMassFromShapes(); <--------- added this.
      }


Lastly, since you are using such a larger scaled world, the mouseJoint needed a much larger force to move the collider shape. If you think about it, your body is 20 meters in diameter and had a density of 10.0( which I reduced to 1.0 btw ) so its massive in relation to what box2d expects.

md.maxForce = 1000000000; <--------- that's 100,000,000

With those changes it works quite well.
Awesome, thanks for the help. Still getting used to the whole scaling thing. I always work in pixels 😛

Original thread: https://box2d.org/forum/viewtopic.php?t=4143