Game Development Community

Projectile timed explosion or collision question

by Sabrecyd · in Torque Game Engine · 03/13/2002 (5:34 am) · 3 replies

Hi,

Sorry, if this seems like a simple question but I'm still picking up on the Torque scripting.

My question is how to make a projectile explode using a timer or delay I know about using the settings below (modified rifle.cs) but what I'd like to do is have a projectile start a timer during the onFire action (or where appropriate) and use the onCollision action if there is one, else have a timed explosion (in air for example). Anyone know the best way to go about doing this? The arming delay below still needs a collison to cause the explosion.

armingDelay = 300;
lifetime = 5000;
fadeDelay = 1500;
bounceElasticity = 0.3;
bounceFriction = 0.2;
isBallistic = true;
gravityMod = 0.10;

function RifleProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal) // (%this,%obj,%col,%fade,%pos,%normal)
{// Apply damage to the object all shape base objects
if (%col.getType() & $TypeMasks::ShapeBaseObjectType)
%col.damage(%obj,%pos,%this.directDamage,"RifleBullet");

// Radius damage is a support scripts defined in radiusDamage.cs
radiusDamage(%obj,%pos,%this.damageRadius,%this.radiusDamage,"RifleBullet",0);}

#1
03/13/2002 (12:05 pm)
Schedule the explosion on the bullet object, so if it collides it blows up cancelling the explosion, but if it's still in the air it will blow up.
#2
03/13/2002 (12:52 pm)
ok, that makes sense. I'll play around with it tonight and see if I can get it to work. Thanks for the reply Matt.
#3
03/14/2002 (5:22 am)
Anyone know how to trigger a projectile (or any object with an explosion data block) to explode without using the onCollision method? I'm pretty sure I have the scheduled timer part down ok, but I can't get the projectile class object to explode without a collision.

Any generic example would greatly help. I think some other people were trying to do something similar (grenades, timebomb, C4, etc) but I haven't been able to find any explosion triggering examples on the site so far.

- never mind, another thread covered it. Whoops, didn't think editing caused a bump. Sorry.