Proper steps in Behavior creation: currently frustrated
by rennie moffat · in Torque Game Builder · 11/09/2009 (2:48 pm) · 1 replies
HI guys, I have a quick run down list to follow, steps I am taking patterns I am understanding to help me in my programming. I have been off for a week due to illness and vacation (vacation first, illness after) but I digress. I am just programming a very simple input behavior, with just one bind key, up. When I hit up, the object should move up.
My steps are to name the behavior, insure a behaviorfield is up,
connect them all in onbehavioradd
using onUpdate and the moveUp function, I would think this would work.
but it isn't, this is SOOOOOOO frustrating. I know this is a newb question and many of you might not have time but if there is a glaring error, something I am missing please tell me. There are no errors in the compiler it runs, but just does not work. If I am making an OBVIOUS ERROR, please tell me. I have gotten this to work before so why won't it now? Could it be a simple syntax error or something major.
My steps are to name the behavior, insure a behaviorfield is up,
if(!isObject(Spacer3000Controls))
{
%template = new behaviorTemplate(Spacer3000Controls);
%template.friendlyName = "Spacer3000 Controls";
%template.behaviorType = "Player Input";
%template.description = "Spacer3000 Controls";
%template.addBehaviorField(upKey, "Controls Up Movement", keybind, "keyboard up");
%template.addBehaviorField(upSpeed, "speed of object up", float, 30.0);
}connect them all in onbehavioradd
function Spacer3000Controls::onBehaviorAdd(%this)
{
if (!isObject(moveMap))
return;
%this.enableUpdateCallback();
moveMap.bindObj(getWord(%this.upKey, 0), getWord(%this.upKey, 1), "moveUp", %this);
%this.up = 0;
}using onUpdate and the moveUp function, I would think this would work.
[function Spacer3000Controls::onUpdate(%this)
{
%this.owner.setLinearVelocityY((%this.up) * %this.upSpeed);
}
function Spacer3000Controls::moveUp(%this, %val)
{
%this.up = %val;
}but it isn't, this is SOOOOOOO frustrating. I know this is a newb question and many of you might not have time but if there is a glaring error, something I am missing please tell me. There are no errors in the compiler it runs, but just does not work. If I am making an OBVIOUS ERROR, please tell me. I have gotten this to work before so why won't it now? Could it be a simple syntax error or something major.
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
Torque Owner rennie moffat
Renman3000
Currently, not that frustrated.