Author Topic: Projectile That Never Dies  (Read 1202 times)

Is it possible to make a projectile that never dies until it his something?

Set lifetime to an extremely high number?

The console complains if you set the lifetime to over 1023.

I guess you have to catch it in ::onDelete (or similar) and spawn a new projectile if it didn't hit anything.

MyProjectile::onRemove(%this) {
    %this.setName("myProjectileToDupe");
    new Projectile(:myProjectileToDupe) {
        initialPosition = %this.getPosition();
    };
}


Something like that should work.

MyProjectile::onRemove(%this) {
    %this.setName("myProjectileToDupe");
    new Projectile(:myProjectileToDupe) {
        initialPosition = %this.getPosition();
    };
}


Something like that should work.
Wouldn't this also cause projectiles to fly through walls?

There probably needs to be a filter for projectiles that hit something.

try overriding the collision to set collided Boolean to true? then parent the collision, and onremove check collided

and is there a variable for the lifetime left on a projectile?
if there is, you could keep resetting it

and is there a variable for the lifetime left on a projectile?
if there is, you could keep resetting it
The number of ticks a projectile can live is stored in the datablock. When you spawn a projectile it'll count up every tick until the number is reached, then delete the object. Unfortunately the counter can't be accessed from torquescript though...

sounds like the best ways to do this are either the collision + remove functions, or a schedule to spawn in a new projectile

do schedules get deleted automatically if the object is deleted? otherwise have it shorter than the projectile lifespan, and have that spawn in the new projectile and delete the itself

The console complains if you set the lifetime to over 1023.
i doubt its really that