I've got a ghostObject that I'm using to build a kinematic player controller, and I understand that when the ghost object overlaps a rigidbody I want to apply a force to the rigidbody to push it away from the ghostObject.
However I'm a little confused about what is the proper sequence for doing so.
Assuming that I am using both the pre and post-tick simulation callbacks, I was thinking something along the following:
preTick {
move ghost kinematic body to new position based on velocity and timestep
}
...simulation step runs, updates collision information...
postTick {
check for collisions against the ghost object
move ghost object to be non-overlapping (recover from penetration)
apply force to rigidbodies in response to collision
}
However reading the tick callback wiki page leads me to believe that this is all wrong and won't do anything. It says the forces are always cleared at the end of the post tick callback, so this won't actually do any pushing at all.
However I can't apply forces in the preTick because I don't know if any collisions have happened yet as a result of the timestep. So how are you supposed to properly push objects if you can't apply a force after a collision occurs?
How (when) to push rigidbodies via forces (pre or post tick)
-
- Posts: 6
- Joined: Thu Oct 14, 2010 2:00 am
-
- Posts: 9
- Joined: Mon Oct 18, 2010 8:53 am
Re: How (when) to push rigidbodies via forces (pre or post t
When you call applyImpulse() on an object, its velocity is modified. Forces aren't needed anymore.