Game Development Community

Physics a bit sticky!!! Ball in maze gets stuck on walls. How to fix?

by Andy Hawkins · in iTorque 2D · 08/05/2012 (8:53 am) · 4 replies

I have almost completed my ball rolling game demo. It's the kind where you have a ball and you tilt the device to move it through a wooden maze avoiding the holes. The problem I have is that I have collision scene objects set up to block the ball and when the ball hits them hard the ball sticks. The collision responses are as follows. I really need the ball to just stop and roll on rather than stick. How is it done?

A collision block
new t2dSceneObject() {
         canSaveDynamicFields = "1";
         PlatformTarget = "IPAD";
         Position = "-213.801 24.352";
         size = "27.602 108.703";
         CollisionActiveSend = "1";
         CollisionActiveReceive = "1";
         CollisionMaxIterations = "3";
         CollisionResponseMode = "RIGID";
         AlphaTestValue = "-1";
            mountID = "43";
      };

The ball...
new t2dStaticSprite(Ball) {
         imageMap = "pinballImageMap";
         frame = "0";
         mUseSourceRect = "0";
         sourceRect = "0 0 0 0";
         canSaveDynamicFields = "1";
         PlatformTarget = "IPAD";
         useMouseEvents = "1";
         Position = "409.488 -281.157";
         size = "37.218 37.728";
         CollisionActiveSend = "1";
         CollisionActiveReceive = "1";
         CollisionCallback = "1";
         CollisionCircleScale = "0.8";
         CollisionMaxIterations = "3";
         CollisionDetectionMode = "CIRCLE";
         CollisionResponseMode = "RIGID";
         CollisionPolyList = "-0.986 -0.280 -0.717 -0.688 -0.418 -0.913 -0.114 -1.000 0.169 -1.000 0.503 -0.874 0.772 -0.633 0.986 -0.255 1.000 0.128 0.901 0.471 0.672 0.742 0.378 0.933 0.010 1.000 -0.329 0.953 -0.617 0.771 -0.861 0.491 -1.000 0.118";
         AlphaTestValue = "-1";
         UsesPhysics = "1";
         Density = "1";
         Friction = "0.01";
         Restitution = "0.01";
         LinkPoints = "0.000 0.000 0.180 0.194 0.327 0.361";
            mountID = "7";
            xOld = "308.598";
            yOld = "-19.389";
         _behavior0 = "TouchDrag";
         _behavior1 = "AccelControl";
      };
www.drewfx.com/Torque/iPhone/BlockmazeSplashScreen3_iphone.png

#1
08/05/2012 (8:55 am)
Sorry about that - @Mod, please delete all but this one - the editing seemed to duplicate the post...
#2
09/05/2012 (3:02 pm)
Hey Andy -

You ever get this working?
#3
09/05/2012 (4:44 pm)
No but I have some theories.

The ball restitution is 1.0 so it maybe constantly spinning and so is essentially always pushing against the walls.

Or that I am picking up angular velocity which is not removed on contact with the walls - so it's angular velocity plus friction means it's always moving.

I'm going to try reduce restitution first to have a more realistic fix, then if that doesn't work, in an update method I'm going to set angular velocity to zero every cycle.
#4
09/05/2012 (5:54 pm)
I can't remember if the bounds box has anything to do with it checking for imminent collisions. ..but I think there is a setting that allows the primitive used to prepare for collision otherwise if it's moving to fast, it would calculate too late and become stuck.

It's been 1.5 years since I messed with it, so I could be wayyy off here but I felt it would be worth a mention.