Removing behaviors?
by Mike Kowalski · in Torque Game Builder · 11/23/2008 (11:20 am) · 2 replies
Greetings, I have been having some trouble getting my game to remove behaviors from my player. Basically I have a player that can switch movement behaviors at the press of a key, and I can create new instances of behaviors with no problems.
(I'd toss this thread in behaviors, but I think it's more a general question than about behaviors)
The documentation says:
removeBehavior(BehaviorInstance bi,[bool deleteBehavior=true])
Params: bi: The behavior instance to remove deleteBehavior: Whether or not to delete the behavior Return:
bool success: Whether the behavior was successfully removed
So I went and setup:
%turn = AlignToJoystickBehavior.createinstance();
%move = ThrusterControlsBehavior.createinstance();
%hover =insertbehaviornamehere.createinstance();
if(player.form $= "FormA")
{
player.removebehavior(%turn, (1));
player.removebehavior(%move,(1));
player.addbehavior(%hover);
}
}
Based on what the documentation said, I believe I'm calling it correctly, and the console doesn't have any script compilation errors. Am I missing something?
Thanks in advance for any help!
(I'd toss this thread in behaviors, but I think it's more a general question than about behaviors)
The documentation says:
removeBehavior(BehaviorInstance bi,[bool deleteBehavior=true])
Params: bi: The behavior instance to remove deleteBehavior: Whether or not to delete the behavior Return:
bool success: Whether the behavior was successfully removed
So I went and setup:
%turn = AlignToJoystickBehavior.createinstance();
%move = ThrusterControlsBehavior.createinstance();
%hover =insertbehaviornamehere.createinstance();
if(player.form $= "FormA")
{
player.removebehavior(%turn, (1));
player.removebehavior(%move,(1));
player.addbehavior(%hover);
}
}
Based on what the documentation said, I believe I'm calling it correctly, and the console doesn't have any script compilation errors. Am I missing something?
Thanks in advance for any help!
About the author
Torque 3D Owner Matthew Langley
Torque
%turn = player.getBehavior(AlignToJoystickBehavior);
player.removeBehavior(%turn, true);