Why is my camera constantly shaking?
here's my script.
public class ThirdPersonCameraController : MonoBehaviour { [SerializeField] private float _RotationSpeed = 1; public Transform Target, Player; float MouseX, MouseY; [SerializeField] private Camera _AimCamera; [SerializeField] private Camera _MainCamera;
void Start()
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
_MainCamera.gameObject.SetActive(true);
_AimCamera.gameObject.SetActive(false);
}
private void LateUpdate()
{
CamControl();
}
void CamControl()
{
MouseX += Input.GetAxis("Mouse X") * _RotationSpeed;
MouseY -= Input.GetAxis("Mouse Y") * _RotationSpeed;
MouseY = Mathf.Clamp(MouseY, -23f, 70f);
transform.LookAt(Target);
if(Input.GetKey(KeyCode.LeftAlt))
{
Target.rotation = Quaternion.Euler(MouseY, MouseX, 0);
}
else
{
Target.rotation = Quaternion.Euler(MouseY, MouseX, 0);
Player.rotation = Quaternion.Euler(0, MouseX, 0);
}
if(Input.GetKeyDown(KeyCode.Mouse1))
{
_MainCamera.gameObject.SetActive(false);
_AimCamera.gameObject.SetActive(true);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How I can make my camera keep a distance between two objects? 0 Answers
Change Camera Position when pressing a button whilst changing scenes 1 Answer
scene bug, 0 Answers
Camera issues; objects are not showing up. 0 Answers
camera wont stop stuttering 0 Answers