Quick player movement question
by Holmida · in Torque Game Builder · 08/30/2011 (11:27 am) · 2 replies
Hi, some quick question. I want my player object to run when I press the movement keys, and I want him to walk when I press movement + other key ("k", for example). This is how I've done this:
Now some little pieces of code inside the player movement functions:
The thing is, when I add the "k" and boolean lines and functions to the code, the player ALWAYS walks instead of running. It seems that the bool variable is always at "true", but I can't see why. Any ideas?
Than you all in advantage.
function playerClass::onLevelLoaded(%this, %scenegraph)
{
$player = %this;
moveMap.bindCmd(keyboard, "left", "playerLeft();", "playerLeftStop();");
moveMap.bindCmd(keyboard, "right", "playerRight();", "playerRightStop();");
moveMap.bindCmd(keyboard, "space", "playerJump();", "");
moveMap.bindCmd(keyboard, "k", "setBoolValue();", "setBoolValueRelease();");
%this.enableUpdateCallback();
}
function setBoolValue()
{
$booleano = true;
}
function setBoolValueRelease()
{
$booleano = false;
}Now some little pieces of code inside the player movement functions:
if ($booleano = false)
{
%this.setLinearVelocityX(-30);
}else
{
%this.setLinearVelocityX(-15);
}if ($booleano = false)
{
%this.setLinearVelocityX(30);
}else
{
%this.setLinearVelocityX(15);
}The thing is, when I add the "k" and boolean lines and functions to the code, the player ALWAYS walks instead of running. It seems that the bool variable is always at "true", but I can't see why. Any ideas?
Than you all in advantage.
About the author
Torque 3D Owner Eric Armstrong
Bloody Tongue Games