Freelook in 1st Person Mode
by Damian Sloane · in Torque Game Engine · 03/12/2007 (3:36 am) · 3 replies
I can only seem to get freelook ($mvFreeLook = true;) to work in 3rd person, what needs to be done to have this work in 1st person?
About the author
#2
In the end I had to go into the engine code and add a new move type to the MoveManager class ("mYawFree") and changed a bit of code in the Player class as well.
If anybody ever wants to know how its done feel free to drop me a message and I'll put it in a resource.
03/13/2007 (6:27 am)
The problem did turn out to be that you can't turn freelook on for one yaw change, and then off for the other. As both of these get bundled together with only the last change to freelook having any effect.In the end I had to go into the engine code and add a new move type to the MoveManager class ("mYawFree") and changed a bit of code in the Player class as well.
If anybody ever wants to know how its done feel free to drop me a message and I'll put it in a resource.
#3
03/13/2007 (8:40 am)
Make the resource :)
Torque Owner Damian Sloane
Player.CC (Line 1422)
Just removed all the checks for "(isMounted() && getMountNode() == 0)" and "!con->isFirstPerson()" and its now freelooking in 1st person mode all the time.
Also removed the head recentering so I could freelook independently of what my legs were doing.
if (move->freeLook) // && ((isMounted() && getMountNode() == 0) || (con && !con->isFirstPerson()))) { mHead.z = mClampF(mHead.z + y, -mDataBlock->maxFreelookAngle, mDataBlock->maxFreelookAngle); } else { mRot.z += y; // Rotate the head back to the front, center horizontal // as well if we're controlling another object. //mHead.z *= 0.5; //if (mControlObject) // mHead.x *= 0.5; }However now I've got another problem, I've now setup 'a' and 'd' to turn left/right, while my mouse controls freelook yaw/pitch.
moveMap.bind( keyboard, a, turnleft ); moveMap.bind( keyboard, d, turnright ); function turnLeft( %val ) { $mvFreeLook = false; $mvYawRightSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0; } function turnRight( %val ) { $mvFreeLook = false; $mvYawLeftSpeed = %val ? $Pref::Input::KeyboardTurnSpeed : 0; } moveMap.bind( mouse, xaxis, yaw ); moveMap.bind( mouse, yaxis, pitch ); function yaw(%val) { $mvFreeLook = true; $mvYaw += getMouseAdjustAmount(%val); } function pitch(%val) { $mvFreeLook = true; $mvPitch += getMouseAdjustAmount(%val); }All works, except... Lets say I hold down 'a' and turn left continuously. Yay I'm a ballerina.
Then while still turning I move the mouse right, magically my head starts drifting back to the left as long as i'm holding 'a' down.
The same works in the opposite direction with the 'd' key down.
I'm thinking both the moves get bundled in the same message to the engine, such that one call to "$mvFreeLook = true/false" from the mouse/keyboard cancels the other out (Does that make sense).