Timed projectile
by Jacob Dankovchik · in Torque Game Engine · 01/28/2005 (3:57 pm) · 7 replies
I need to make a timed projectile, was wondering how i could go about doing this. Need it to fire a projectile then after a couple of seconds of flying, explodes. Anyone got ideas, or may this need minor engine additions? Hope not..
About the author
#2
01/28/2005 (5:31 pm)
Hm.. k.. i guess i'll try fiddlin around with the engine and try to make it explode instead.. I'll post it i nthe engine forums if i come up with anything.
#3
01/29/2005 (6:50 am)
Hm. tried the engine work, havin issues with it.. Gonna keep workin with that, but for now just wonderin. How would i use a schedule command for calling a scripted command?
#4
As to the scheduling thing, sorry, never figured that out either X_X I'll post back if I see anything like this, since I need a similar effect too
01/29/2005 (6:55 am)
@Eric i think it's fadedelay for how many ms before it just fades out. As to the scheduling thing, sorry, never figured that out either X_X I'll post back if I see anything like this, since I need a similar effect too
#5
That is the only thing that schedule is used for. There are probably examples in starter.fps. If not, check some of Mark Holcomb's resources. He uses schedule to decide the next time his bots should do some thinking. You can also look up schedule in this reference:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6853
01/29/2005 (8:57 am)
>How would i use a schedule command for calling a scripted command?That is the only thing that schedule is used for. There are probably examples in starter.fps. If not, check some of Mark Holcomb's resources. He uses schedule to decide the next time his bots should do some thinking. You can also look up schedule in this reference:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6853
#6
01/29/2005 (9:56 am)
Ok, kept messin around and i finally got it workin pretty much. The explosion now detonates as it should. Next im going to make it damage in the area and touch things up and i'll post it here. Turns it outs nothing more then a simple script mod.. heh.
#7
First, add this above CrossbowImage::onFire
then add this before your mission cleanup:
And it should work! :D
01/29/2005 (10:22 am)
Ok, i tihnk it got it workin. I noticed one odd thing however. If the projectile hits something right when it runs out of time, it'll make 2 explosions. Seems like maybe the collision doesn't remove it soon enough or something. You all can have a look and try it out, see what happens.. But this is the basic..First, add this above CrossbowImage::onFire
function CrossbowProjectile::MakeExplosion(%this, %obj) //explosion funtion
{
%pos = %obj.getPosition(); //set position
%p = new explosion() { //make explosion
dataBlock = "CrossbowExplosion";
position = %pos;
};
radiusDamage(%obj,%pos,%this.damageRadius,%this.radiusDamage,"Crossbow",0); //damage
%obj.delete(); //kill it off
}then add this before your mission cleanup:
%projectile.schedule(2000,MakeExplosion, %p); //schedule the explosion
And it should work! :D
Torque Owner Eric Lavigne
If you are doing it in script, use the schedule command to time it. When it is time to blow, just drop an invisible but collideable object in front of it. A dumb hack? Yes. I'm pretty sure it would work though.