Author Topic: How to spawn explosion?  (Read 1236 times)

I'm making an item called the TNT and I need to know how to spawn the explosion right when they click.  I tried several things, but none worked...
I really need to know how to do this.  Please help me!

Spawn a projectile (look at any 'spread gun' mod or the Tank) at the place you need and then do %projectile.explode() to make it explode. You'll need a ProjectileData datablock as well to make this work.

It's not working
I'm not sure if I did it the right way though:
Code: [Select]
function TNTImage::onPreFire(%p)
{
%p = new Projectile()
            {
               dataBlock = TNTProjectile;
               projectile.explode()
            };
}

remove projectile.explode() and add %p.explode(); below the };

It didn't work
This is what it looks like:
Code: [Select]
function TNTImage::onPreFire(%p)
{
%p = new Projectile()
            {
               dataBlock = TNTProjectile;
            };
%p.explode();
}

Well ofcourse it's not going to work.
You don't even have initialpositon.

This is what I have now:
Code: [Select]
function TNTImage::onPreFire(%p)
{
%p = new Projectile()
            {
               dataBlock = TNTProjectile;
               initialPosition =
            };
%p.explode();
}

What do I put in the initialPosition area if I want it to explode right on the player?

This is painful to watch. You don't even understand the syntax. There are countless examples of spawning projectiles via script. Stop being lazy.

I'm a new scripter, I don't know how to script that well.  Therefor, I need some help sometimes.  I really want to release this weapon.  I tryed to look up how to do it in a Torque Scripting Reference, but it didn't have anything on it.

There are countless examples of spawning projectiles via script. Stop being lazy.


I looked at the tank and that's how I got the code, but it only shows the explosion light D:

Code: [Select]
function TNTImage::onPreFire(%c)
{
%p = new Projectile()
            {
               dataBlock = TNTProjectile;
               Position = %c.player.getPosition();
            };
%p.explode();
}
I think that will work unless the function has different args.

initialposition*
However an initialvelocity is nice to have for using rotation.

initialposition*
However an initialvelocity is nice to have for using rotation.
I think Position would work too, when I spawn anything else I use Position =.