Saturday, July 24, 2010

Exposing object's linear velocity during collision.

Prototyping with TGB is very easy and straightforward process. Afret first 30 minutes I have my UFO and a few objects to colide with.



Some extra code was needed though to expose UFO's linear velocity to the script, so that I will be able to calculate impact damage during collision.

I added the following code to the t2dPhysics::resolveClampCollision method, at the end of if ( solveDst ) statement:

// notify the colliding object about its linear speed during impact 
F32 currentCollisionSpeed = linearVelocity.len();
Con::executef( 
   pCollisionStatus->mDstObject, 
   2, 
   "processCollisionImpact",
   Con::getFloatArg(currentCollisionSpeed) 
);
That way every time my UFO hits another object, the following script funcion will be called:

function player::processCollisionImpact( %this, %collisionSpeed )
{
}

No comments:

Post a Comment