Game Development Community

Dismount problem / issue

by Adam Griffiths · in Torque Game Builder · 03/12/2008 (5:15 am) · 1 replies

I have been using the behaviour playground code to release a mounted object, the code:

if (!isObject(GenericInputActionBehavior))
{
   %template = new BehaviorTemplate(GenericInputActionBehavior);
   
   %template.friendlyName = "Generic Input Action";
   %template.behaviorType = "Input";
   %template.description = "Executes a command when the specified key is pressed";
   
   %template.addBehaviorField(actionKey, "The key that triggers the command", keybind, "keyboard enter");
   %template.addBehaviorField(command, "The Torque Script function to call", string, "");
}

function GenericInputActionBehavior::onAddToScene(%this, %scenegraph)
{
   if (!isObject(moveMap))
      return;
   
   moveMap.bind(getWord(%this.actionKey, 0), getWord(%this.actionKey, 1), %this.command);
}


The problem i'm having is that the mounted object will not release or dismount using any kind of command i use.

the key is bound to "enter"
the commands i've used are:

dismount()
dismount();
.dismount()
.dismount();
%this.dismount()
%this.dismount();
nameofobject.dismount()
nameofobject.dismount();

and others similar to the above, when i bring up the console it states "Unknown Command", however, if i type in nameofobject.dismount() (into the console) it releases the object perfectly??

so manually it works just as i wanted (via the console), but via the behaviour it will not dismount the object. Could anyone shed any light on the problem i'm having?

Many thanks, as always.

#1
03/12/2008 (6:36 am)
Just a wild guess here, but you could try

%this.owner.dismount();

You could also put in a line of debug code prior to see what object your actually dealing with, i.e

echo("Class = ", %this.Class());
echo("Owner Class = ", %this.owner.Class());

Just a couple of suggestions ... it just sounds like that the object your code is trying to dismount isnt actually the object your expecting it to be - I've had this problem with a piece of code last week.