Game Development Community

%this gets lost

by Kevin James · in Torque Game Builder · 05/06/2010 (6:09 am) · 3 replies

Sometimes in the onUpdate callback, %this loses its reference.

For example,

function npcship::fireMissile(%this)
{
   //snip 

   %this.schedule(%this.fireDelay(), "fireMissile");
}

function npcship::fireDelay()
{
   //%this gets lost here for some reason - can't use ship.firerate
   %rate =$player.fireRate * 1000;
}

The work around is to use a global variable but its not ideal. Is this a known issue or is it just me?

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
05/06/2010 (6:11 am)
Nevermind.. I saw it as soon as I clicked submit DOH!
#2
05/06/2010 (6:51 am)
and the magic fix was... don't forget you need to include %this as the first parameter in Torque Script? :)
#3
05/06/2010 (7:41 am)
Yes! I keep getting burnt by that.