Question by
BernardoAndrade · Oct 14, 2020 at 01:45 PM ·
camera-movementcamera rotatecamera follow
I want to make the player move in the same direction that the camera moves
This is my code of camera movement: But the player is moving in the world axis instead of chaging as i change the camera rotation
void Start()
{
rotation.y = transform.eulerAngles.y;
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
// PLAYER AND CAMERA ROTATION
pAndC_Rotation();
}
public void pAndC_Rotation()
{
rotation.y += Input.GetAxis("Mouse X") * lookSpeed;
rotation.x += -Input.GetAxis("Mouse Y") * lookSpeed;
rotation.x = Mathf.Clamp(rotation.x, -lookXLimit, lookXLimit);
playerCameraParent.localRotation = Quaternion.Euler(rotation.x, 0, 0);
transform.eulerAngles = new Vector2(0, rotation.y);
}
}
Comment