Quantcast
Channel: Questions in topic: "issue"
Viewing all articles
Browse latest Browse all 827

player isn't rotating along y-axis

$
0
0
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

Viewing all articles
Browse latest Browse all 827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>