Question by
dariam11 · Jun 23, 2020 at 12:56 PM ·
third-person-camera
Need help with Third Person camera mouse look,How to make a TP camera rotate left and right plus follow my character
So far I got this code writen and it does the rotation up and down perfectly and it rotated the player, right now am trying to implement so the camera rotates to the sides while being outside the player prefab so it does not rotates it and it follow the player but every time i try it makes the axis go opposite and it has a limit to the right
void CameraMovement()
{
if (!canMoveCamera)
return;
float mouseY = Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
float mouseX = Input.GetAxis("Mouse X") * sensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90, 90);
transform.localRotation = Quaternion.Euler(xRotation, 0, 0);
Player.Rotate(Vector3.up * mouseX);
},So far I got this code but i tried adding a code for the camera to rotate from left to right but it does it in a wierd way and the axis go the oposite way, plus it has a limit position
void CameraMovement()
{
if (!canMoveCamera)
return;
float mouseY = Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
float mouseX = Input.GetAxis("Mouse X") * sensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90, 90);
transform.localRotation = Quaternion.Euler(xRotation, 0, 0);
Player.Rotate(Vector3.up * mouseX);
}
Comment