Game Development Community

OnUpdate for object created inside behavior

by Man-Machine · in Torque Game Builder · 04/08/2009 (2:31 am) · 3 replies

I have this code on a behavior function:

%projectile = %this.missile.cloneWithBehaviors();
%projectile.enableUpdateCallback();

Now how do I use this object on a OnUpdate callback function inside the behavior. Or is it not possible?

Thank you



#1
04/08/2009 (3:26 am)
I think you'll have to assign your object to a class like this:

%projectile.class = "SomeClass";

And have some code in an onUpdate function like this:

function SomeClass::onUpdate(%this)
{
   // put some code here
}
#2
04/08/2009 (9:50 am)
Thanks but I couldn't get that to work. There must be more to it...
#3
04/08/2009 (11:34 am)
Oh I just see that your attempt to enable the update callback won't work.

Something like this should get the update callback working

function YourBehavior::onAddToScene(%this, %scenegraph)
{
   %this.owner.enableUpdateCallback();
}

function YourBehavior::onUpdate(%this)
{
   // some code...
}