Game Development Community

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:

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

#1
12/22/2007 (8:20 am)
Oh wait, I bet this is something to do with collision lists for the bullet not getting updated as it moves. Anyone know what functions I need to call to get that to happen?
#3
12/28/2007 (11:29 am)
Ok, I found it. Need to call t2dSceneObject::updateSpatialConfig().

Ian