Game Development Community

Physic not work?

by tianjie_gs · in iTorque 2D · 07/05/2011 (11:58 pm) · 3 replies

Hi, I meet some problem here.
I try to test the physic system, I create a StaticSprite that use physics and collision, set the gravity, and run the game, but I didn't see my sprite fall down to the floor, it just stay on its position. I think may be the iTGB physics system just pass some parameter, so I attach a behavior to the sprite force it move down, that works , but when the sprite fall I didn't get any collision call back with my floor(a scene object which receive collision). I don't know what is going wrong here, maybe I miss something important, help….

#1
07/06/2011 (8:15 am)
re: collisions. Make sure your collisionCallback is set to true.





As far as gravity, not sure, I use constantForceY
#2
07/06/2011 (8:59 am)
The gravity thing is a tad confusing at first, I think due to the way it is implemented in the editor.

Checking the gravity box does NOT apply gravity to an object, thus causing it to fall. As Rennie stated, you need to use a constant force, most likely in the positive Y. The gravity checkbox just tells the engine to treat the constant force like gravity - IE the mass of an object is irrelevant like in the real world.

As for your collisions, i'm not sure. I've not had any problems with it. Make sure you have the appropriate checkboxes on everything involved in the collisions, Make sure callbacks are set. Double check your callback code to ensure you have the proper class/object names, and functions specified. It certainly should work.
#3
07/06/2011 (8:20 pm)
I find my mistake, I confuse with the collision layer and group, that is my fault.
Now the collision work good,
and the physics just works, I can focus on other things, thanks for your help.