Game Development Community

My fire effect

by Orion the Hunter · in Torque Game Builder · 01/12/2013 (1:09 pm) · 3 replies

Hello, I was wondering if there was something wrong with this code:
function pskProjectile::onCollision( %ourObject, %theirObject, %ourRef, %theirRef, %time, %normal, %contacts, %points )
{
    // Trigger Impact?
    if ( !%ourObject.triggerImpact( %theirObject ) )
    {
        // Quit.
        return;
    }
    
    // Actor?
    if ( %theirObject.isMemberOfClass( "pskActor" ) )
    {
        // Damage the Target.
        %theirObject.takeDamage( %ourObject.ProjectileDamage, %ourObject, true, true );
    }

    if ( %OurObject.isMemberOfClass( "BurningPineConeProjectile" ) )
    {
    %effect = new t2dParticleEffect()
    {
      scenegraph = %this.getSceneGraph();
      Name = "Fire";
      effectFile = "~/data/particles/FireEffect.eff";
      useEffectCollisions = "1";
      effectMode = "KILL";
      lifeTime = "3000";
      canSaveDynamicFields = "1";
      Position = "41.000 -6.000";
      size = "8.000 8.000";
      CollisionMaxIterations = "1";
         mountID = "149";
    };

  %link = %effect.mount(%theirObject, "0 0");
  %effect.playEffect(true);
  %effect.isPlaying = true;
  %this.BurnActor();
    }


    //There's sometimes a little trouble with this part so we're fixing it...
    if ( %theirObject.isMemberOfClass( "SnakeClass" ) )
    {
        // Damage the Target.
        %theirObject.takeDamage( %ourObject.ProjectileDamage, %ourObject, true, true );
    }

}

function pskProjectile::BurnActor( %this, %ourObject, %theirObject )
{
if( isObject( Fire ) )
    {
       %theirObject.takeDamage( 25, %ourObject, true, true );
        %this.schedule(1000, 0, "BurnActor");
    }
}
The problem is that it (obviously) doesn't work.

The projectile fires but when it hits the target, the fire effect is not spawned and it doesn't burn them away. Any help is greatly appreciated!

#1
01/12/2013 (5:36 pm)
Do you need to pass %ourObject, %theirObject in

%this.BurnActor(%ourObject, %theirObject);

Where are %ourObject, %theirObject defined? Do they contain any data?

Perhaps you could echo them out in BurnActor, and maybe remove isObject for now and see if it calls the function.
#2
01/13/2013 (12:30 pm)
Huh. I tried it and it didn't work... No errors from the console, I think my BurnActor function is just messed up.
#3
01/14/2013 (4:07 am)
Is the "BurningPineConeProjectile" a C++ class you wrote? If not, you should be using:

if (%ourObject.class $= "BurningPineConeProjectile"), not isMemberOfClass.