Constant Force causing jittery movement.
by Cory Leach · in iTorque 2D · 06/15/2011 (6:18 am) · 6 replies
In short: I'm getting jittery unclean collisions when my constant y force is too big but it has to be big to look like natural gravity.
I wanted to play with iT2D physics and so naturally I'm attempting to simulate gravity using a constant force. I started a new project and added a few rectangles(Polygons) to the scene. I'm not even using images just filled polygons. I left the camera at default and put one rectangle in the air and one rectangle as the immovable ground. When I added the constant force to the scene at first I just tried adding the usual 9.8 to the Y value for the magnitude of gravity but the result was an extremely slow crawl. To get something that looks even close to natural gravity I had to set the constant y force to a really high number like 4,000. At 1,000 the force collision appears fine the box hits the ground and does not appear to move but the motion it too slow so I upped the force to 4,000 and that is when I get a more natural speed of gravity but at the edge which collides with the ground polygon I see a very jittery shaky movement.
I thought maybe I could fix it by changing the fps or step of the physics system but when I tried calling setScenePhysicsMaxIterations I found those functions don't exist in iT2D (Also in the process discovered that in iT2D there is no console which was also an annoyance. I realize that it can be seen in the xcode console but really annoying to have to build every time. Isn't not having to build every time the point of using scripting language?)
I've been using TGB and iTorque 2D for several days now and while it makes the layout of levels and things very convenient to create there seems to be many little quirks that make life more difficult than it should have to be. iT2D collision/physics system doesn't appear to be as fully featured and intuitive as it could be. Definitely one area that could use some more thought and improvement. It would be nice to be able to set up physics in iT2D that work as well as the cocos2d+Box2d/Chipmunk combo without having to hack the source.
I wanted to play with iT2D physics and so naturally I'm attempting to simulate gravity using a constant force. I started a new project and added a few rectangles(Polygons) to the scene. I'm not even using images just filled polygons. I left the camera at default and put one rectangle in the air and one rectangle as the immovable ground. When I added the constant force to the scene at first I just tried adding the usual 9.8 to the Y value for the magnitude of gravity but the result was an extremely slow crawl. To get something that looks even close to natural gravity I had to set the constant y force to a really high number like 4,000. At 1,000 the force collision appears fine the box hits the ground and does not appear to move but the motion it too slow so I upped the force to 4,000 and that is when I get a more natural speed of gravity but at the edge which collides with the ground polygon I see a very jittery shaky movement.
I thought maybe I could fix it by changing the fps or step of the physics system but when I tried calling setScenePhysicsMaxIterations I found those functions don't exist in iT2D (Also in the process discovered that in iT2D there is no console which was also an annoyance. I realize that it can be seen in the xcode console but really annoying to have to build every time. Isn't not having to build every time the point of using scripting language?)
I've been using TGB and iTorque 2D for several days now and while it makes the layout of levels and things very convenient to create there seems to be many little quirks that make life more difficult than it should have to be. iT2D collision/physics system doesn't appear to be as fully featured and intuitive as it could be. Definitely one area that could use some more thought and improvement. It would be nice to be able to set up physics in iT2D that work as well as the cocos2d+Box2d/Chipmunk combo without having to hack the source.
About the author
Recent Threads
#2
Did you remove friction?
07/11/2011 (3:21 am)
I am currently using constantForceY to simulate gravity. Mine is set to 300 and works fine. I suppose everything is relative. The object I apply gravity (constantForceY) to is about 1/100th of the screen size (rough guess but it is small). Did you remove friction?
#3
07/11/2011 (4:35 am)
Right, it seems there is no simple way to solve this problem for the really high values. I haven't confirmed this but I would bet that if you just scale your objects down smaller and then also scale the camera view accordingly so that a force of around 300 looks like natural gravity it would probably work fine. Still annoying though.
#4
07/11/2011 (6:18 am)
I am actually only using a force of 200, yet I get the jittering. But interestingly I only get it in one direction. If my constant force is +y, I get no jitter. If its +x I get jitter. I suspect it has to do with the space between the objects, and their physics properties. I am pretty sure what is happening is the forces aren't being reconciled properly under certain circumstances.datablock t2dSceneObjectDatablock(gameTile) {
canSaveDynamicFields = "1";
class = "gameTileClass";
useMouseEvents = "1";
WorldLimitMode = "BOUNCE";
WorldLimitMin = "-160.000 -240.000";
WorldLimitMax = "160.000 240.000";
WorldLimitCallback = "1";
CollisionActiveSend = "1";
CollisionActiveReceive = "1";
CollisionCallback = "1";
CollisionMaxIterations = "3";
CollisionResponseMode = "BOUNCE";
UsesPhysics = "1";
ConstantForce = "200.000 0.000";
ConstantForceGravitic = "1";
ForceScale = "2";
Restitution = "0.5";
damping = "0.8";
mountID = "6";
Type = "blank";
};
#5
One thing I do not use is "Gravatic" tho. I believe that may be a "funky" function.
07/11/2011 (6:25 pm)
Perhaps your masses and density's are out of wack.One thing I do not use is "Gravatic" tho. I believe that may be a "funky" function.
#6
change
const U32 ITickable::smTickShift = 5;
to
const U32 ITickable::smTickShift = 4;
07/15/2011 (12:27 pm)
to fix this edit iTickable.ccchange
const U32 ITickable::smTickShift = 5;
to
const U32 ITickable::smTickShift = 4;
Torque Owner John Vanderbeck
VanderGames