Hey can someone help me with my camera script ?
I was working on my new project and i was have a problem where when i move (the game is in first person) the camera sometimes jumps instead of a smooth transition I was wondering if someone could look in to it and try to fix it . I know about the smoothdamp() and leth() but i have no idea how to use it or more like how to implement it to the code. I am a beginner when it comes to coding.
Here is the code that I use :
public class CameraScript : MonoBehaviour
{
public float mousesensitivity = 200f;
public float smoothTime = 0.3F;
public Transform playerbody;
float xRotation = 0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mousesensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mousesensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -80f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerbody.Rotate(Vector3.up * mouseX);
}
}
Also a note in Unity I placed the camera inside of the Empty Object thats where i placed Players body and also a ground check for my movement script if needed i can also send my movement script as well.
Your answer
Follow this Question
Related Questions
Having text be a child to a game object? 2 Answers
Show Text where user clicks in a panel,Show text where User clicks 0 Answers
Camera keeps going behind walls/floor 1 Answer
Any way to increase raycast range? 0 Answers
c# multiple camera help 1 Answer