Movement troubles
by Jay Mertz · in Torque Game Engine · 10/30/2007 (12:41 pm) · 5 replies
I need to have my character to turn left/right. I would like to move the character with the arrow keys or mouse, doesnt matter. I dont know the code in which this will work. here is the code I speculate is where I need to change:
default.binds.cs
------------------------
// Movement Keys
default.binds.cs
------------------------
// Movement Keys
$movementSpeed = 1; // m/s
function setSpeed(%speed)
{
if(%speed)
$movementSpeed = %speed;
}
function moveleft(%val)
{
$mvLeftAction = %val * $movementSpeed;
}
function moveright(%val)
{
$mvRightAction = %val * $movementSpeed;
}
function moveforward(%val)
{
$mvForwardAction = %val * $movementSpeed;
}
function movebackward(%val)
{
$mvBackwardAction = %val * $movementSpeed;
}
function moveup(%val)
{
$mvUpAction = %val * $movementSpeed;
}
function movedown(%val)
{
$mvDownAction = %val * $movementSpeed;
}
[b]function turnLeft( %val )
{
$mvYawRightSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function turnRight( %val )
{
$mvYawLeftSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
[/b]
function panUp( %val )
{
$mvPitchDownSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function panDown( %val )
{
$mvPitchUpSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function getMouseAdjustAmount(%val)
{
// based on a default camera fov of 90'
return(%val * ($cameraFov / 90) * 0.01);
}
function yaw(%val)
{
$mvYaw += getMouseAdjustAmount(%val);
}
function pitch(%val)
{
$mvPitch += getMouseAdjustAmount(%val);
}
function jump(%val)
{
$mvTriggerCount2++;
}
function mouseTrigger(%val)
{
$mvTriggerCount0++;
}
moveMap.bind( keyboard, a, moveleft );
moveMap.bind( keyboard, d, moveright );
moveMap.bind( keyboard, w, moveforward );
moveMap.bind( keyboard, s, movebackward );
moveMap.bind( keyboard, space, jump );
moveMap.bind( mouse, xaxis, yaw );
moveMap.bind( mouse, yaxis, pitch );
moveMap.bind( mouse, button0, mouseTrigger );
#2
I use 'Q' and 'E' so adding:
Might help. Personally I like having strafe keys so I prefer not to take them out (a and d).
11/01/2007 (3:54 am)
You need to bind keys to the turnLeft and turnRight functions.I use 'Q' and 'E' so adding:
moveMap.bind( keyboard, q, turnleft ); moveMap.bind( keyboard, e, turnright );
Might help. Personally I like having strafe keys so I prefer not to take them out (a and d).
#3
that worked perfectly, its now working thank you so much!
@ Lee Latham:
I know thats the strangest thing, I didn't change anything. I went through the getting started tutorial and it was doing this all along. I wonder if anybody else had the same problem? But anyways, thank you for your input
11/01/2007 (1:39 pm)
@ Brian West:that worked perfectly, its now working thank you so much!
@ Lee Latham:
I know thats the strangest thing, I didn't change anything. I went through the getting started tutorial and it was doing this all along. I wonder if anybody else had the same problem? But anyways, thank you for your input
#4
are you on a MAC? I am using Torque for MAC and have the exact same problem. The Q and E key solution is great, but why doesn't the mouse work? I don't even know what variables to change to test the mouse. I need the mouse buttons to do the exact same thing as the Q and E above. I wonder if this is just a MAC issue.
01/02/2008 (1:40 am)
Jay,are you on a MAC? I am using Torque for MAC and have the exact same problem. The Q and E key solution is great, but why doesn't the mouse work? I don't even know what variables to change to test the mouse. I need the mouse buttons to do the exact same thing as the Q and E above. I wonder if this is just a MAC issue.
#5
01/09/2008 (5:37 am)
I beilieve this is what you need to do.moveMap.bind( mouse, button0, turnleft ); moveMap.bind( mouse, button1, turnright );
Torque Owner Lee Latham
Default Studio Name
But I can see you've changed the defaults. You should be able to turn left/right with the defaults.