This question was
closed Apr 01, 2020 at 09:10 PM by
rustcrayfish767 for the following reason:
The question is answered, right answer was accepted
Question by
rustcrayfish767 · Apr 01, 2020 at 09:19 AM ·
scripting problem
what is wrong here?
when i was following a tutorial The side to side worked at first and then when I made the up and down It let me look that way but the side to side now moves back and forth snapping back to looking forward and IDK where the code went wrong and It does not say that there are anything wrong so I assume its is my own doing I just cant find it
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class uyg : MonoBehaviour {
public float mousesensitivity = 9f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mousesensitivity;
float mouseY = Input.GetAxis("Mouse Y") * mousesensitivity;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
}
Comment
Follow this Question
Related Questions
example of new way to load levels 1 Answer
"The associated script cannot be loaded" 0 Answers
Global Illumination at Runtime 0 Answers
A graph to render sine wave with custom resolution 0 Answers
only menu1 hides on gui click 1 Answer