Game Development Community

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!

#1
11/26/2008 (3:11 pm)
Maybe try:

%turn = player.getBehavior(AlignToJoystickBehavior);

player.removeBehavior(%turn, true);
#2
11/29/2008 (11:14 am)
Yep that did it! Thanks alot for the fix!