Calling projectile::explode
by Grant McNeil · in Torque Game Engine · 08/30/2006 (12:20 pm) · 3 replies
Hey,
I'm still trying to wrap my head around torquescript, I guess;
I was wondering why in the scripts I can't call %whatever.explode() [assuming %whatever was a Projectile()].
in more detail, I created a projectile %p:
%p = new Projectile() {
dataBlock = CrossbowProjectile;
initialVelocity = 0;
initialPosition = %col.getPosition();
muzzlevelocity = 0;
initialvelocity = "0 0 0";
};
MissionCleanup.add(%p);
and I just want to get it to explode, though calling %p.explode(); just gives me errors. the projectile is created fine, it spawns and sits there as it should, I just want it to blow up.
Thanks.
I'm still trying to wrap my head around torquescript, I guess;
I was wondering why in the scripts I can't call %whatever.explode() [assuming %whatever was a Projectile()].
in more detail, I created a projectile %p:
%p = new Projectile() {
dataBlock = CrossbowProjectile;
initialVelocity = 0;
initialPosition = %col.getPosition();
muzzlevelocity = 0;
initialvelocity = "0 0 0";
};
MissionCleanup.add(%p);
and I just want to get it to explode, though calling %p.explode(); just gives me errors. the projectile is created fine, it spawns and sits there as it should, I just want it to blow up.
Thanks.
About the author
#2
Give the projectile some initialVelocity, so it will actuall move and collide and explode normally. Probably setting the velocity on the inverted normal of what you collided with would be the most accurate method.
Add a small bit of code to make the projectile explode when it ends it's lifetime. However I don't recommend that, as you seem to be just trying to use a projectile to create an explosion here, and explosions tend to look funny without a proper normal being passed in.
Add a method that allows you to create Explosion objects directly. This is what I use for creating explosions from my raycast based weapons.
The last two will require source modifications, where the first is a strictly script hack.
08/30/2006 (12:52 pm)
There is no explode() method for the projectile exposed to script by default. And even if you called it on the server, it wouldn't make the explosion appear on the client. There are a few things you can do here. Give the projectile some initialVelocity, so it will actuall move and collide and explode normally. Probably setting the velocity on the inverted normal of what you collided with would be the most accurate method.
Add a small bit of code to make the projectile explode when it ends it's lifetime. However I don't recommend that, as you seem to be just trying to use a projectile to create an explosion here, and explosions tend to look funny without a proper normal being passed in.
Add a method that allows you to create Explosion objects directly. This is what I use for creating explosions from my raycast based weapons.
The last two will require source modifications, where the first is a strictly script hack.
Torque Owner Stefan Lundmark
Explode is not a consoleFunction of Projectile. There is a function called explode() but it is not exposed to the scripting engine and complications arise if you try to expose it.