Game Development Community

Collision Help

by Ryan Dixon · in Torque Developer Network · 03/28/2010 (2:02 pm) · 1 replies

I am trying to get my missile and enemy ship to collide and delete each other, but no nluck. I am also using the shoots behaviour. My code is in my enemy.cs file. Can'e see what im doing wrong, please help!

function EnemyShip::onCollision( %this, %srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts )
{
if (%dstObj.class $= "pMissile") {
%srcObj.safeDelete();
%dstObj.safeDelete();
}
}


#1
04/07/2010 (5:07 am)
If you're using TGE (and I assume in T3D as well) the projectiles, ie your missles, delete themselves when they collide with something. Your ship may have some sort of onDisabled callback you could use. If not, you could give your ship a 'health' property of some sort, if it doesn't already have one. When the ship is hit be the missile, decrement the 'health'. When the 'health' reaches 0, delete the ship.