- Home /
How Can I Smooth This Camera Code
This is My Cam Class Containing My Camera Variables (Temporarly) public class Cam : MonoBehaviour { //Camera's Values public static int Inverted = 1; //1 If The Camera Controls Are Not Inverted And -1 Otherwise public static float ySens = 5; //Sensitivity Of The Camera (On The yAxis) Varies Between 0.5f And 5 public static float xSens = 5; //Sensitivity Of The Camera (On The xAxis) Varies Between 50 And 1000 public static float Distance = 2; //Height Of The Camera public static float Smoothness = 25; //Smoothness Of The Camera }
My LastUpdate Camera Code:
yAxis += Input.GetAxis("MouseY") * Cam.ySens * (-1 * Cam.Inverted);
transform.rotation = Quaternion.Euler(yAxis, Player.eulerAngles.y, 0);
transform.position = Vector3.Lerp (transform.position, Quaternion.Euler(yAxis, Player.eulerAngles.y, 0) * new Vector3(0, Cam.Distance + Player.position.y, -PawnThickness * 3 - 2 * Player.position.y) + new Vector3(Player.position.x,0,Player.position.z), Cam.Smoothness * Time.deltaTime);
}
And My Pawn's xAxis Rotation:
//Rotate Pawn According To Mouse's X Axis
if (Input.GetAxis ("MouseX") != 0)
PawnTrans.Rotate (0, Input.GetAxis("MouseX") * 50 * Cam.xSens * Time.deltaTime, 0);
My Problem is the Camera's Rotation On The xAxis is not Smooth (This Part:
transform.rotation = Quaternion.Euler(yAxis, Player.eulerAngles.y, 0);
If I Alter The 0 Value To Smoothen It I Get Choppy Camera Movement. Plz Help!
Your answer
Follow this Question
Related Questions
Smooth Attached Object movement 1 Answer
Camera, Look rotation, smoothly? 0 Answers
smoothly rotate camera around an object with momentum 0 Answers
Move and rotate the camera at the same time 2 Answers
Smooth Rotation 2 Answers