Simulating collision "outside" of the sim
by Ian Omroth Hardingham · in Torque Game Builder · 12/22/2007 (8:14 am) · 3 replies
Hey guys.
I'm prototyping a turn based game and have a need to simulate collisions for several seconds of "game time" in a single function call.
Say we have a simple case where there's just one bullet moving down the screen:
Unfortunately, this isn't working - I've set up a good test case where similar code catches the collision if it's being run in "real time", but not when running multiple "ticks" at once.
Any help on what the problem might be would be greatly appreciated.
Thanks,
Ian
I'm prototyping a turn based game and have a need to simulate collisions for several seconds of "game time" in a single function call.
Say we have a simple case where there's just one bullet moving down the screen:
for (F32 i = 0; i < 5; i += 0.032)
{
// first, set the velocity to be the bullet's velocity
// this will never actually move the bullet, but will be used for the collision cast
bullet->setLinearVelocity(t2vector(0, 5));
t2dPhysics::cCollisionStatus collisionStatus;
// cast collision over the next "tick", 0.032 seconds
if (bullet->castCollision(0.032, &collisionStatus))
{
// do whatever we want to do if the collision is got
}
// now we actually "perform" the move
bullet->setPosition(bullet->getPosition() + t2vector(0,5));
}Unfortunately, this isn't working - I've set up a good test case where similar code catches the collision if it's being run in "real time", but not when running multiple "ticks" at once.
Any help on what the problem might be would be greatly appreciated.
Thanks,
Ian
About the author
Designer and lead programmer on Frozen Synapse, Frozen Endzone, and Determinance. Co-owner of Mode 7 Games.
Associate Ian Omroth Hardingham
Mode 7 Games