Set a Projectile to explode itself at a specified time
by Michael Cozzolino · 03/17/2006 (6:57 pm) · 11 comments
Download Code File
If you ever wanted your projectile to explode at a certain time if it doesn't hit something first instead of just fading away. This resource will let you do that.
You just set two properties in your projectile datablock.
explodeOnExplodeTime = true; // boolean value [true if you want it to blow on expiration of explode time
explosiontime = 300; // time that passes before explosion happens barring having a collision first.
Included files in Resource:
crossbow.cs // has changes projectile datablock to demonstrate resource
projectile.cc // modified so resource works
projectile.h // modified so resource works
If you ever wanted your projectile to explode at a certain time if it doesn't hit something first instead of just fading away. This resource will let you do that.
You just set two properties in your projectile datablock.
explodeOnExplodeTime = true; // boolean value [true if you want it to blow on expiration of explode time
explosiontime = 300; // time that passes before explosion happens barring having a collision first.
Included files in Resource:
crossbow.cs // has changes projectile datablock to demonstrate resource
projectile.cc // modified so resource works
projectile.h // modified so resource works
About the author
Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489
#2
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9678
That resource will fix the problem.
03/18/2006 (10:40 am)
If anyone plans to use this resource for a nade you may find that when the nade is stationary it vibrateshttp://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9678
That resource will fix the problem.
#3
03/18/2006 (12:44 pm)
So this should fix the explosion issues for grenades we had with the explosions not showing up client side then?
#4
I'm not dismissing this resource as what it enables you to do is very handy, I just want to know why people have resorted to scheduling an explosion which wont work across the network?
03/18/2006 (7:41 pm)
To get a projectile to bounce and explode across a network you shouldn't have to make any head code changes. I use a projectile for grenades similar to this and it bounces and explodes just fine, even over a network.datablock ProjectileData(grenadeThrownProjectile)
{
projectileShapeName = "~/data/shapes/m26grenade/m26grenade_projectile.dts";
directDamage = 100;
radiusDamage = 40;
damageRadius = 35;
areaImpulse = 1500;
explosion = grenadeExplosion;
muzzleVelocity = 10;
velInheritFactor = 0.6;
particleEmitter = streamerEmitter;
armingDelay = 3000;
lifetime = 12000;
fadeDelay = 12000;
bounceElasticity = 0.6;
bounceFriction = 0.4;
isBallistic = true;
gravityMod = 0.5;
shakeCamera = false;
};I'm not dismissing this resource as what it enables you to do is very handy, I just want to know why people have resorted to scheduling an explosion which wont work across the network?
#5
03/20/2006 (6:10 am)
The way we are dealing with grenades is we have the grenade as an item that is thrown then we schedule a projectile to spawn at the location of the grenade item and remove the item.
#6
explosiontime to a low value. Since projectiles explosions are sent to all of the clients it works.
03/20/2006 (9:43 am)
C2 :Yes as long as you are not scheduling an explosion. You schedule a projectile instead and set it's explosiontime to a low value. Since projectiles explosions are sent to all of the clients it works.
#7
7>..\engine\game\projectile.cc(827) : error C2660: 'Projectile::explode' : function does not take 3 arguments
08/26/2006 (4:06 pm)
funny i am getting this error:7>..\engine\game\projectile.cc(827) : error C2660: 'Projectile::explode' : function does not take 3 arguments
#8
I know there were changes to projectile.cc for TSE and I altered this resource for our project. If you are using 1.42 RC that could be the issue as well since I don't haven't DL'ed it I can't say for sure.
08/28/2006 (9:50 am)
@Night are you using this against Torque 1.4 ?I know there were changes to projectile.cc for TSE and I altered this resource for our project. If you are using 1.42 RC that could be the issue as well since I don't haven't DL'ed it I can't say for sure.
#9
09/06/2006 (6:27 pm)
yes i am using 1.4 and it will compile if it takes 5 arguments
#10
EDIT: Will see if I get a chance to add a ExplodeTimeRandom var to that.
12/05/2007 (12:06 pm)
Cool resourse, thanx. Works with TGEA.EDIT: Will see if I get a chance to add a ExplodeTimeRandom var to that.
#11
if(isServerObject() && mCurrTick >= mDataBlock->explodetime && mDataBlock->explodeOnExplodeTime == true)
you should remove the isServerObject() check or your explosions will fail on the client about 50% of the time.
06/05/2009 (10:19 pm)
This old resource works perfectly, provided you make 1 change. In Projectile::processTick, in the line:if(isServerObject() && mCurrTick >= mDataBlock->explodetime && mDataBlock->explodeOnExplodeTime == true)
you should remove the isServerObject() check or your explosions will fail on the client about 50% of the time.
Torque 3D Owner Willbkool