Not sure if this is a bug, or if I’m doing something wrong as this is my first WebGL game.
I have very basic first person movement controls, they work fine in the editor but when I build my scene the camera is constantly rotating down. I can fight it by sliding the mouse up(or add to it by sliding the mouse down), but I can’t figure out what’s causing it.
I can’t seem to find anyone else with this problem, but this feels like a glitch. Any thoughts?
Here’s my code, just in case:
public Transform playerBody;
public float xSpeed = 100f;
public float ySpeed = 100f;
public bool invxAxis = false;
private float yRotation = 0.0f;
private float xRotation = 0.0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
float mouseY = Input.GetAxis("Mouse Y") * xSpeed * Time.deltaTime;
float mouseX = Input.GetAxis("Mouse X") * ySpeed * Time.deltaTime;
if (invxAxis == true)
{
xRotation += mouseY;
}
else
{
xRotation -= mouseY;
}
yRotation += mouseX;
xRotation = Mathf.Clamp(xRotation, -80f, 80f);
//yRotation += mouseX;
playerBody.localRotation = Quaternion.Euler(xRotation, yRotation, 0f);
}
}