setGraviticConstantForce(%gravitic)
by rennie moffat · in Torque Game Builder · 10/05/2009 (3:18 pm) · 2 replies
So i have just made my own behavior, I can not see what is wrong here but I would think this should work, must be a minor error I am unaware of. Please check it out if you have a minute.
if (!isObject(Spacer3000))
{
%template = new BehaviorTemplate(Spacer3000);
%template.friendlyName = "Spacer3000 Controls";
%template.behaviorType = "Input";
%template.description = "Spacer3000Controls";
%template.addBehaviorField(leftKey, "Key to bind leftthurst", keybind, "keyboard left");
%template.addBehaviorField(rightKey, "Key to bind rightthrust", keybind, "keyboard right");
%template.addBehaviorField(downKey, "Key to bind downthrust", keybind, "keyboard down");
%template.addbehaviorField(upKey, "Key to bind upthrust", keybind, "keyboard up");
%template.addBehaviorField(ThrustAmount, "Amount of thrust placed on Object", float, 30);
}
function Spacer3000::onBehaviorAdd(%this)
{
if(!isObject(MoveMap))
return;
%this.owner.enableUpdateCallback();
moveMap.bindObj(getWord(%this.upKey, 0), getWord(%this.upKey, 1), "moveUp", %this);
moveMap.bindObj(getWord(%this.downKey, 0), getWord(%this.downKey, 1), "moveDown", %this);
moveMap.bindObj(getWord(%this.leftKey, 0), getWord(%this.leftKey, 1), "moveLeft", %this);
moveMap.bindObj(getWord(%this.rightKey, 0), getWord(%this.rightKey, 1), "moveRight", %this);
%this.up = 0;
%this.down = 0;
%this.left = 0;
%this.right = 0;
}
function Spacer3000::onBehaviorRemove(%this)
{
if(!isObject(moveMap))
return;
%this.owner.disableUpdateCallback();
moveMap.unbindObj(getWord(%this.upKey, 0), getWord(%this.upKey, 1), "moveUp", %this);
moveMap.unbindObj(getWord(%this.downKey, 0), getWord(%this.downKey, 1), "moveDown", %this);
moveMap.unbindObj(getWord(%this.leftKey, 0), getWord(%this.leftKey, 1), "moveLeft", %this);
moveMap.unbindObj(getWord(%this.rightKey, 0), getWord(%this.rightKey, 1), "moveRight", %this);
%this.up = 0;
%this.down = 0;
%this.left = 0;
%this.right = 0;
}
function Spacer3000::moveUp(%this, %val)
{
%this.up = %val;
}
function Spacer3000::moveDown(%this, %val)
{
%this.down = %val;
}
function Spacer3000::moveLeft(%this, %val)
{
%this.left = %val;
}
function Spacer3000::moveRight(%this, %val)
{
%this.right = %val;
}
function Spacer3000::onUpdate(%this)
{
if(%this.right == 1)
{
%this.owner.setLinearVelocityPolar(%this.owner.rotation, (%this.up - %this.down) * %this.acceleration);
%this.owner.setLinearVelocityPolar(getWord(%speed, 0), getWord(%angle, 1));
%this.owner.setAngularVelocity((%this.right - %this.left) * %this.turnSpeed);
}
if(%this.left == 1)
{
%this.owner.setLinearVelocityPolar(-30, 300);
}
if(%this.up == 1)
{
%this.owner.setLinearVelocityPolar(0, -30);
}
if(%this.down == 1)
{
%this.owner.setLinearVelocityPolar(0, 30);
}
} 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.
#2
If only I could have it read my thoughts. haha!
ANyways,
I went back and edited it slightly, you can see I removed the setFriction and setConstantForcePolar. Essentially I have it working now. I am just adjusting angles. Thanks!
10/05/2009 (5:26 pm)
Thanks,If only I could have it read my thoughts. haha!
ANyways,
I went back and edited it slightly, you can see I removed the setFriction and setConstantForcePolar. Essentially I have it working now. I am just adjusting angles. Thanks!
Associate William Lee Sims
Machine Code Games
Also function parameters must be in the proper format as mentioned in www.garagegames.com/community/forums/viewthread/101395/1#comment-674381 and in www.garagegames.com/community/forums/viewthread/102915/1#comment-682559.
Finally, many of your behavior fields are not being used. I'm guessing without a bit of work, it won't actually do what you think it will.
Good luck!