- Home /
Question by
zaidan1193 · May 02 at 07:27 PM ·
cameramovementquaternioncamera-movementcamera rotate
how do you sway the camera based on sharp turns
So I'm trying to add more feedback into my game at the moment, and something I'm trying to add at the moment is trying to tilt the camera when the player does sharp turns as his sprinting. This is my camera movement code:
yRotation += mouseX * sensX; //X Rotation
xRotation += mouseY * sensY; //Y Rotation
Vector3 camVelocity = Vector3.zero; //Some Useless stuff
xRotation = Mathf.Clamp(xRotation,-cameraClampValues, cameraClampValues); //Camera Clamping Values
cameraHolder.transform.localRotation = Quaternion.Euler(-xRotation, yRotation, 0); //Rotation
orientation.transform.rotation = Quaternion.Euler(0f, yRotation, 0f); //Orientation Rotation
cameraHolder.transform.position = orientation.transform.position ; //Fixes Jittering Bug & Adds Y-Offset
Now, I'm trying to add a value for the z rotation of the camera holder, and that value is the one that will be based on how fast I've done those sharp turns. I'm unsure on how to calculate it though, does anyone have any idea? Thanks anyway and have a great day!
Comment