Game Development Community

A second explosion at time of OnCollision

by Michael Cozzolino · in Torque Game Engine · 07/17/2002 (9:13 am) · 4 replies

Ok I submitted a code snippit for adding a blood explosion on collision but learned that it doesn't work client side. I am about to give up on figuring this out.I am wondering if it is possible to spawn an explosion at the position of the collision? So I could do:


function RifleProjectile::onCollision(%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");


if (%col.getclassName() $= "player") {

//Create an Explosion
}

}

About the author

Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489


#1
07/17/2002 (10:07 am)
You can create explosions "on-the-fly" at any location, take a look here...
Don't know what may be the problem with your code not working client-side though... can we see it somewhere?
#2
07/17/2002 (11:18 am)
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2884 Here is my code snipit. I didn't realize before that I couldn't change data from datablocks on the fly. It works fine server side but there is no explosion whatsoever client side.

I have been trying to use Labrats www.garagegames.com/index.php?sec=mg&mod=forums&page=result.thread&qt=4177 blowup function and modifying it slightly to try to get it to schedule an explosion OnCollsion instead of OnFire but I think the %obj is destroyed before I can have it explode.

I checked out your code but I found it a little confusing. It could be because my brain is fried though. :)
#3
07/18/2002 (6:56 am)
This is easy.
In the ExplosionData datablock for the type of explosion you want to do, say for the CrossbowExplosion datablock found in crossbow.cs you do something like this:
datablock ExplosionData(CrossbowExplosion)
{
   subExplosion[0] = CrossbowSubExplosion1;
   subExplosion[1] = CrossbowSubExplosion2;
   subExplosion[2] = CrossbowSubExplosion3;

   emitter = CrossbowExplosionEmitter;
   
   shakeCamera = true;
   camShakeFreq = "10.0 11.0 10.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 10.0;

   // Dynamic light
   lightStartRadius = 6;
   lightEndRadius = 3;
   lightStartColor = "0.5 0.5 0";
   lightEndColor = " 0 0 0";
};

datablock ExplosionData(CrossbowSubExplosion1)
{
   explosionShape = "~/data/shapes/crossbow/explosion.dts";
   faceViewer           = true;
   delayMS = 100;
   offset = 3.0;
   playSpeed = 1.5;

   sizes[0] = "0.75 0.75 0.75";
   sizes[1] = "1.0  1.0  1.0";
   sizes[2] = "0.5 0.5 0.5";
   times[0] = 0.0;
   times[1] = 0.5;
   times[2] = 1.0;

};
// added
datablock ExplosionData(CrossbowSubExplosion2)
{
   explosionShape = "~/data/shapes/crossbow/explosion.dts";
   faceViewer           = true;
   delayMS = 50;
   offset = 3.0;
   playSpeed = 0.75;

   sizes[0] = "1.5 1.5 1.5";
   sizes[1] = "1.5 1.5 1.5";
   sizes[2] = "1.0 1.0 1.0";
   times[0] = 0.0;
   times[1] = 0.5;
   times[2] = 1.0;
};
// added
datablock ExplosionData(CrossbowSubExplosion3)
{
   explosionShape = "~/data/shapes/crossbow/explosion.dts";
   faceViewer           = true;
   delayMS = 0;
   offset = 0.0;
   playSpeed = 0.5;

   sizes[0] = "1.0 1.0 1.0";
   sizes[1] = "2.0 2.0 2.0";
   sizes[2] = "1.5 1.5 1.5";
   times[0] = 0.0;
   times[1] = 0.5;
   times[2] = 1.0;

};

You don't have to specify a shape, but you can if you want, you can do anything a normal ExplosionData block can do such as color and so forth. In this particular case you'll get 3 explosions spawned in the same rough location as the first explosion.
#4
07/18/2002 (7:20 am)
Robert I see what you are doing but these Sub explosions would occur everytime no matter what the projectile collides with right? I'm trying to have the second explosion only happen if a player object is hit with the projectile. Labrats example of spawning explosions works great because I call it OnCollision and get the position but there seems to be a "bug" that crashes a dedicated server. I don't know if this "bug" is being addressed at this time though.