remapping for custom action maps
by Stefan Beffy Moises · in Torque Game Engine · 06/24/2002 (4:44 am) · 7 replies
Hi there!
I have a custom ActionMap which gets pushed if the player enters a vehicle (where I remap the movement keys and add some additional keybinds for braking, etc.).
The question is: (how) do I get these mappings into the "Controls" options gui where the user then can remap these new car functions to his preferred keys?
I've tried to add it "the usual way":
Any ideas how to do this without writing a new "Car Controls" dialog?
Thanx!
I have a custom ActionMap which gets pushed if the player enters a vehicle (where I remap the movement keys and add some additional keybinds for braking, etc.).
The question is: (how) do I get these mappings into the "Controls" options gui where the user then can remap these new car functions to his preferred keys?
I've tried to add it "the usual way":
$RemapName[$RemapCount] = "Car - Steer left"; $RemapCmd[$RemapCount] = "steerLeft"; $RemapCount++; ...but then I'm also overwriting/changing the "normal" MoveMap ... e.g. if I remap "s" to "brakeVehicle", it is changed in the MoveMap, too ...
Any ideas how to do this without writing a new "Car Controls" dialog?
Thanx!
About the author
#2
Well, simply steering with the keyboard is easy, although it's not very comfortable (see my current other thread concerning this...
Anyhow, here's what I use at the moment...
steerLeft and steerRight do exactly the same as turnRight/turnRight for now (in default.bind.cs):
does this help??
06/24/2002 (9:00 am)
Err... sure! I assume you got your vehicle working and mounted and controlled via mouse/keyboard?Well, simply steering with the keyboard is easy, although it's not very comfortable (see my current other thread concerning this...
Anyhow, here's what I use at the moment...
steerLeft and steerRight do exactly the same as turnRight/turnRight for now (in default.bind.cs):
function steerLeft( %val )
{
$mvYawRightSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}
function steerRight( %val )
{
$mvYawLeftSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0;
}As soon as the vehicle is mounted (player.cs, Armor::onCollision()), I push a new ActionMap:CarDriveMap.push();The ActionMap itself is in my car.cs:
new ActionMap(CarDriveMap); CarDriveMap.bind(keyboard, "right", steerRight); CarDriveMap.bind(keyboard, "left", steerLeft); CarDriveMap.bind(keyboard, "up", moveForward); CarDriveMap.bind(keyboard, "down", movebackward); CarDriveMap.bind(keyboard, "q", applyBrake); CarDriveMap.bind(keyboard, "+", increaseCamDist); CarDriveMap.bind(keyboard, "-", decreaseCamDist); CarDriveMap.bind(keyboard, ".", increaseCamOffset); CarDriveMap.bind(keyboard, ",", decreaseCamOffset);and I pop it in Armor::doDismount()...
does this help??
#4
06/24/2002 (9:49 am)
It worked like a charm, many Thanks. Also how would you make it so the mouse doesn't effect the steering anymore. I got the keyboard working but the mouse also control the wheels. The ultimate plan is to bind the mouse to a turret on the car.
#5
cause in wheeledVehicle, the "brakes" were bound to trigger[2], which is the jump trigger and which is used to unmount from any vehicle, unfortunately...
So you have to change the trigger, I use the "fire" trigger for braking now:
06/24/2002 (10:13 pm)
Well, preventing the mouse from steering is an easy one, simply remap it to something else:CarDriveMap.bind(mouse0, "xaxis", moveTurret);To get the applyBrake function working was a bit tricky,
cause in wheeledVehicle, the "brakes" were bound to trigger[2], which is the jump trigger and which is used to unmount from any vehicle, unfortunately...
So you have to change the trigger, I use the "fire" trigger for braking now:
void WheeledVehicle::updateMove(const Move* move)
{
Parent::updateMove(move);
// Break on trigger
//mBraking = move->trigger[2];
// changed from jump to fire trigger, cause jump is used for dismouting... (beffy)
mBraking = move->trigger[0];
...Then, applyBrake simply activates the fire trigger like this:function applyBrake(%val)
{
$mvTriggerCount0++;
}So now anytime I press "q" or the firebutton (which is still mapped for firing, too), my car is braking... and "space" (aka "jump") is still unmounting the player from the car.
#6
06/24/2002 (10:15 pm)
Anyhow, does anybody have solutions for me to get these mappings into the options screen or resetting the steering to the center after releasing the "steer" keys?
#7
06/25/2002 (12:37 pm)
Well, I don't know if you'd consider it a solution... I ended up duplicating most of the existing code under a new name and pane in the options dialog. I need to come up with a more elegant solution, but it seems to work well enough for the time being.
Associate Anthony Rosenbaum