need help with $mvYaw and $mvPitch
by deepscratch · in Torque 3D Professional · 08/24/2011 (6:36 pm) · 10 replies
hi all,
I'm trying to get vehicle control from keyboard, success with that so far,
except with flying vehicles.
I am set up for permanent free look when mounted to vehicles,
and its great,
till you need pitch control or yaw control,
the keypress does its job, but pitches/yaws the camera as well, try as I may, I cant stop it from controlling the cam when doing a yaw or pitch action.
please, anyone have any ideas on this?
on how to stop it controlling the cam on these 2 moves.
thanks
I'm trying to get vehicle control from keyboard, success with that so far,
except with flying vehicles.
I am set up for permanent free look when mounted to vehicles,
and its great,
till you need pitch control or yaw control,
the keypress does its job, but pitches/yaws the camera as well, try as I may, I cant stop it from controlling the cam when doing a yaw or pitch action.
please, anyone have any ideas on this?
on how to stop it controlling the cam on these 2 moves.
thanks
About the author
email me at medan121@gmail.com
Recent Threads
#2
Define the ActionMaps in the default.bind.cs:
Add this functions on the scripts/client/commands.cs:
And on scripts/server/player.cs, edit the Armor::onMount function to change the active ActionMap. Like this:
08/29/2011 (4:05 pm)
I did not understand what you need. But if your goal is to have different mappings (and thus keys disabled or enabled), for each type of vehicle. This may help you. Is part of the script that i use to change the mapping of the keyboard and joypad, depending on the vehicle on which the player mount.Define the ActionMaps in the default.bind.cs:
if ( isObject( vehicleMap ) ) vehicleMap.delete(); new ActionMap(vehicleMap); if ( isObject( heliDriverMap ) ) heliDriverMap.delete(); new ActionMap(heliDriverMap); if ( isObject( heliPassengerMap ) ) heliPassengerMap.delete(); new ActionMap(heliPassengerMap); // ------------------------------------ // Default WhelledVehicle // ------------------------------------ vehicleMap.bind( keyboard, w, moveforward ); .... // ------------------------------------ // Default HeliVehicle // ------------------------------------ heliDriverMap.bindCmd(keyboard, "escape", "", "escapeFromGame();"); .... // ------------------------------------ // Passenger WhelledVehicle // ------------------------------------ heliPassengerMap.bindCmd(keyboard, "escape", "", "escapeFromGame();"); ....
Add this functions on the scripts/client/commands.cs:
//----------------------------------------------------------------------------
// Vehicle commands
//----------------------------------------------------------------------------
function clientCmdtoggleVehicleMap(%toggle)
{
if(%toggle)
{
moveMap.pop();
vehicleMap.push();
}
else
{
vehicleMap.pop();
moveMap.push();
}
}
function clientCmdtoggleHeliMap(%toggle)
{
if(%toggle)
{
moveMap.pop();
heliDriverMap.push();
}
else
{
heliDriverMap.pop();
moveMap.push();
}
}
function clientCmdtoggleHeliPassengeMap(%toggle)
{
if(%toggle)
{
moveMap.pop();
heliPassengerMap.push();
}
else
{
heliDriverMap.pop();
heliPassengerMap.push();
}
}And on scripts/server/player.cs, edit the Armor::onMount function to change the active ActionMap. Like this:
if(%obj.getClassName() $= "Player" || %db.getClassName() $= "WheeledVehicleData" )
commandToClient(%obj.client, 'toggleVehicleMap', true);
//%obj.client.setObjectActiveImage(%vehicle, 2);
if(%obj.getClassName() $= "Player" || %db.getClassName() $= "heliVehicleData" )
commandToClient(%obj.client, 'toggleHeliMap', true);
#3
@Alfio - he wants to use the mouse to look and the keyboard to yaw and pitch the vehicle but using the keys moves the camera and steers the vehicle at the same time. So, somehow camera control and steering control mapping are tied together somewhere - like the right mouse button with alt-fire and jump jets.
08/29/2011 (5:47 pm)
It sounds like the more common issue of trying to separate alt-fire and jump jets. I'm not sure where to look for either one, but I understand what you mean there.@Alfio - he wants to use the mouse to look and the keyboard to yaw and pitch the vehicle but using the keys moves the camera and steers the vehicle at the same time. So, somehow camera control and steering control mapping are tied together somewhere - like the right mouse button with alt-fire and jump jets.
#4
08/29/2011 (7:35 pm)
Just disable the moveMap (moveMap is a ActionMap), and enable an alternative ActionMap that does not include what he does not need and bind the yaw and pitch with the keys he wants.
#5
thats exactly the issue, yes.
@Alfio,
I do use seperate moveMaps,
and have found no way at all to stop the yaw/pitch moves, from the keyboard, from affecting both vehicle AND camera,
I am sure its hardcoded somewhere...but where??
08/30/2011 (1:02 am)
@Richard,thats exactly the issue, yes.
@Alfio,
I do use seperate moveMaps,
and have found no way at all to stop the yaw/pitch moves, from the keyboard, from affecting both vehicle AND camera,
I am sure its hardcoded somewhere...but where??
#6
08/30/2011 (6:19 am)
Someone managed to break jump and jet from each other - I wish I could find that again.... lol
#7
08/30/2011 (9:02 am)
Maybe the pitch is changing because the camera is mounted to the vehicle and rotates when it does. To resolve that you may need to reverse the rotation and apply it back to the camera. When the vehicle pitches down 5 degrees, pitch the camera up by 5 degrees.
#8
I thought about that, but it would create jitter when moving the mouse to look at the same time while pitching/yawing with the keyboard
08/30/2011 (11:47 am)
@Rex,I thought about that, but it would create jitter when moving the mouse to look at the same time while pitching/yawing with the keyboard
#9
I haven't looked at the code for where all of this happens so I really can't say it would work like that.
Other than that, you might be able to look at the point in the code where a mounted camera is moved in relation to the vehicle and override where it is setting the rotation and only let it set the position of the camera.
08/30/2011 (1:38 pm)
I would think you would code it so that it is additive. If you are moving the mouse to look up, you add that value. The camera pitch is now the new value. You then evaluate the changing pitch of the vehicle and adjust the (now updated) pitch of the camera.I haven't looked at the code for where all of this happens so I really can't say it would work like that.
Other than that, you might be able to look at the point in the code where a mounted camera is moved in relation to the vehicle and override where it is setting the rotation and only let it set the position of the camera.
#10
I also had to make a change in Player::updateMove. I commented out the following lines:
Hopefully this may help you. In my case, I am able to rotate my player and have him shoot while the right mouse button is down, and I'm still able to control the craft with the keyboard, without affecting the camera.
08/30/2011 (6:09 pm)
I have a setup that is similar to what you are trying to accomplish. I'm using a hovercraft instead of a flying vehicle, but the solution may be similar. I set it up so that when the player mounts the vehicle, holding down the right mouse button allows the player to freely rotate ( in order to fire his weapon). I made the changes in player.cpp in the processTick function. My changes are between the JAM comments.PROFILE_SCOPE(Player_ProcessTick);
// If we're not being controlled by a client, let the
// AI sub-module get a chance at producing a move.
Move aiMove;
if (!move && isServerObject() && getAIMove(&aiMove))
move = &aiMove;
// Manage the control object and filter moves for the player
Move pMove,cMove;
if (mControlObject) {
if (!move)
mControlObject->processTick(0);
else {
pMove = NullMove;
cMove = *move;
if (isMounted()) {
//start JAM Filter mouse triggers if mounted
pMove.trigger[0] = move->trigger[0];
cMove.trigger[0] = false;
pMove.trigger[1] = move->trigger[1];
cMove.trigger[1] = false;
if (MoveManager::rightMouseButtonDown)
{
pMove.yaw = move->yaw;
pMove.pitch = move->pitch;
pMove.roll = move->roll;
cMove.yaw = cMove.pitch = cMove.roll = 0.0f;
}
//end JAMI also had to make a change in Player::updateMove. I commented out the following lines:
mHead.z *= 0.5f;
if (mControlObject)
mHead.x *= 0.5f;Hopefully this may help you. In my case, I am able to rotate my player and have him shoot while the right mouse button is down, and I'm still able to control the craft with the keyboard, without affecting the camera.
Torque Owner deepscratch
DeepScratchStudios