- Home /
Question by
prashinmore · Jun 04, 2020 at 03:40 PM ·
c#charactercontrollerissuemouselook
player isn't rotating along y-axis
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class MouseLook : MonoBehaviour { public float mouseSpeed = 100f; public Transform playerBody; float xRotation = 0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSpeed * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSpeed * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
}
so the above is my mouselook script code but the playerBody.Rotate(Vector3.up * mouseX); part won't work and the character isn't rotating sideways at all the rest of the scripts are functioning and there are no errors it also rotates up and down but not sideways
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
player isn't rotating along y-axis 1 Answer