Movemap.bind questions (multiple ways of movement)
by Frogger · in Torque Game Engine · 10/31/2003 (6:06 pm) · 34 replies
I was wondering about if I had split screen, could I set up like the arrow buttons of one side and w,s,a,d for the other? I was just wondering what the name for arrows are in the field:
From config.cs -------------- moveMap.bind(keyboard, "--arrow ?--", moveleft); moveMap.bind(keyboard, "--arrow ?--", moveright); moveMap.bind(keyboard, "--arrow ?--", moveforward); moveMap.bind(keyboard, "--arrow ?--", movebackward);Would it also be possible to have both be able to do the same thing like this:
moveMap.bind(keyboard, "arrow ?", moveleft); moveMap.bind(keyboard, "arrow ?", moveright); moveMap.bind(keyboard, "arrow ?", moveforward); moveMap.bind(keyboard, "arrow ?", movebackward); moveMap.bind(keyboard, "a", moveleft); moveMap.bind(keyboard, "d", moveright); moveMap.bind(keyboard, "w", moveforward); moveMap.bind(keyboard, "s", movebackward);Or would that cause errors?
#22
The engine cascades a lot of keybinds, including using the ones from default.binds.cs, and then the ones from config.cs (which are your user defined binds using the options panel). In some cases, if you change a default.binds.cs moveMap (which is where you -should- change it), the engine will over-write it with a previous definition in your config.cs (which again, makes sense from a game play perspective--just not a game dev perspective.
So, if you are re-defining keys for your game, it may be best to define them in default.binds.cs, but then make sure that your config.cs either reflects the change (do it manually--just duplicate the entry), or delete your config.cs and config.cs.dso--they are executable generated every time you run the game.
06/07/2005 (8:25 am)
One thing he is probably running into:The engine cascades a lot of keybinds, including using the ones from default.binds.cs, and then the ones from config.cs (which are your user defined binds using the options panel). In some cases, if you change a default.binds.cs moveMap (which is where you -should- change it), the engine will over-write it with a previous definition in your config.cs (which again, makes sense from a game play perspective--just not a game dev perspective.
So, if you are re-defining keys for your game, it may be best to define them in default.binds.cs, but then make sure that your config.cs either reflects the change (do it manually--just duplicate the entry), or delete your config.cs and config.cs.dso--they are executable generated every time you run the game.
#23
the stuff from the default.bind.cs i posted is from the only default.bind.cs i HAVE.
i only have one default.bind.cs i don't have one for fps demo and one for the racing demo.
these are the only bind.cs files i have
editor.bind.cs
editor.bind.cs.dso
show.bind.cs
default.bind.cs
default.bind.cs.dso
I'm very sorry for not understanding all this correctly. please explane it a bit clearer
(shal i just change the mouse.bind in default.bind.cs to keyboard.bind if so wouldn't that affect the fps demo in wich the player uses the mouse to aim)
regards
bardur
06/07/2005 (9:41 am)
Chris Labombardthe stuff from the default.bind.cs i posted is from the only default.bind.cs i HAVE.
i only have one default.bind.cs i don't have one for fps demo and one for the racing demo.
these are the only bind.cs files i have
editor.bind.cs
editor.bind.cs.dso
show.bind.cs
default.bind.cs
default.bind.cs.dso
I'm very sorry for not understanding all this correctly. please explane it a bit clearer
(shal i just change the mouse.bind in default.bind.cs to keyboard.bind if so wouldn't that affect the fps demo in wich the player uses the mouse to aim)
regards
bardur
#24
You still have to follow what I said about changing it... bind the keys to your own little function to set the yaw.
06/07/2005 (9:43 am)
Fair enough... like I said, I don't have any code in front of me for reference. What keys do what ? does w and s drive and brake and reverse the car ? and does the mouse simply steer ? You still have to follow what I said about changing it... bind the keys to your own little function to set the yaw.
#25
For stearing: "W" forward, "S" backward, "Brakes" Space, and then the mouse is for stearing
what i want is only using W,S,A,D and space NOT the mouse..
how should i bind them should i change the mouse.bind to keyboard.bind? or what this is what i really can't understand
Here are some lines from the default.bind.cs:
------------------------------------------------------------------------------------------------------------------
I hope you can tell me now..
and by the way thanks ALOT for helping me.
Regards
Bardur
06/07/2005 (11:08 am)
Hi again For stearing: "W" forward, "S" backward, "Brakes" Space, and then the mouse is for stearing
what i want is only using W,S,A,D and space NOT the mouse..
how should i bind them should i change the mouse.bind to keyboard.bind? or what this is what i really can't understand
Here are some lines from the default.bind.cs:
------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Movement Keys
//------------------------------------------------------------------------------
$movementSpeed = 1; // m/s
function setSpeed(%speed)
{
if(%speed)
$movementSpeed = %speed;
}
function moveleft(%val)
{
$mvLeftAction = %val;
}
function moveright(%val)
{
$mvRightAction = %val;
}
function moveforward(%val)
{
$mvForwardAction = %val;
}
function movebackward(%val)
{
$mvBackwardAction = %val;
}
function moveup(%val)
{
$mvUpAction = %val;
}
function movedown(%val)
{
$mvDownAction = %val;
}
function turnLeft( %val )
{
$mvYawRightSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function turnRight( %val )
{
$mvYawLeftSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
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++;
}
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 );
//------------------------------------------------------------------------------
// Mouse Trigger
//------------------------------------------------------------------------------
function mouseFire(%val)
{
$mvTriggerCount0++;
}
function altTrigger(%val)
{
$mvTriggerCount1++;
}
moveMap.bind( mouse, button0, mouseFire );
//moveMap.bind( mouse, button1, altTrigger );----------------------------------------------------------------------------------------------------------------------I hope you can tell me now..
and by the way thanks ALOT for helping me.
Regards
Bardur
#26
Do you see a moveLeft function anywhere in the scripts ? What you want to do is make a function called yawKey(%val) ... then, in the moveLeft function call yawKey ... in yawKey you want to set $mvYaw += chris; ... and find a value for chris that works well. It will be a constant turning. You wont get anything gradual like you can with the mouse (as the keys aren't really analog)
06/07/2005 (11:14 am)
Is moveLeft (and moveright) a function, or does it refer directly to the field of the Move struct that gets sent to the player ? Do you see a moveLeft function anywhere in the scripts ? What you want to do is make a function called yawKey(%val) ... then, in the moveLeft function call yawKey ... in yawKey you want to set $mvYaw += chris; ... and find a value for chris that works well. It will be a constant turning. You wont get anything gradual like you can with the mouse (as the keys aren't really analog)
#27
06/07/2005 (11:16 am)
If moveLeft is a function all you really have to do is call $mvYaw += x; where x is a suitable value, inside of the moveLeft funciton
#28
06/07/2005 (11:21 am)
Here is the real Default.bind.cs the other one was one i had fiddled with so there was much NEEDless stuf here is a fresh installed default.bind.cs
#29
there ya go...
EDIT: that will let you use either the mouse or the keys... to disable the mouse just comment out or delete the bind to the yaw for the mouse
06/07/2005 (11:23 am)
function moveleft(%val)
{
$mvLeftAction = %val;
$mvYaw += 20; // ADJUST THIS UNTIL IT FEELSRIGHT
}there ya go...
EDIT: that will let you use either the mouse or the keys... to disable the mouse just comment out or delete the bind to the yaw for the mouse
#30
There is one problem though. and its when i turn, it turns half way when i push the button. and when i release it, it turns fully?
AND i CAN't drive FORWARD when i turn i can't drive forward again?
Now i will try to make some adjustments on my own but THANKS!!
Regards
BArdur
06/07/2005 (11:32 am)
Hi I WORKS! THanks alotThere is one problem though. and its when i turn, it turns half way when i push the button. and when i release it, it turns fully?
AND i CAN't drive FORWARD when i turn i can't drive forward again?
Now i will try to make some adjustments on my own but THANKS!!
Regards
BArdur
#31
:) Good luck getting it working the way you want.
06/07/2005 (11:35 am)
No problem... You might want to try reading through the Torque docs, and fiddling with things yourself until you figure it out... It's really not that difficult, but you got to give it a good effort. Otherwise people will avoid your questions on the forums... Since you will appear to be an individual who doesn't try the problem for themselves first.:) Good luck getting it working the way you want.
#32
To only have it operate once (when the key is pressed), change it to:
06/07/2005 (11:36 am)
The reason that happens is because the function moveleft is actually called TWICE (once for when you press the key, once for when you release the key).To only have it operate once (when the key is pressed), change it to:
function moveleft(%val)
{
if (%val)
{
$mvLeftAction = %val;
$mvYaw += 20;
}
}
#33
whats the reason for that?
Regards
BArdur
06/07/2005 (11:41 am)
I CANt drive FORWARD WTF? when i turn i cant drive forward again?whats the reason for that?
Regards
BArdur
#34
oh... make sure you set the keyboard turn speed variable
06/07/2005 (11:46 am)
Uh... there is a turnLeft function specifically for using the keyboard to turn... why dont you just bind hte key to that ?moveMap.bind( keyboard, a, turnleft ); moveMap.bind( keyboard, d, turnright );
oh... make sure you set the keyboard turn speed variable
Torque Owner Chris Labombard
Premium Preferred
You want to make it so that the keyboard turns the car instead of the mouse, correct ?
Unfortunately, I don't have any code i front of me (at work) ... so I can't look up stuff for you.
Try this out, just to see what happens:
Keep in mind I have no idea how the racing demo works, I have never een seen it.
This is running the assumption that w is accelerator... s is brake... mouse moves you left and right.
That is form the racing demo ? Why the heck do you need pitch ? and you cant move left and right...
If that is the starter.fps default.bind.cs can you please post the equivalent calls from the racing demo ?