- Home /
Question by
Zeepblok · Feb 21, 2020 at 02:02 PM ·
mousepositionmouselookorientation
SpaceSim Mouse movement while upside down
Hi,
I'm making a 3d space game where you fly a ship. its first person from the cockpit. All my movements work like a charm (W = speed up, S = speed down, Q = rotate left, R = rotate right) and the mouse moves the ship arount. But if I use my rotate buttons the mouse stays "stuck" easiest to explain is when I fly normal moving the mouse up pans the camera up and down pans down. But if I fly upside down the mouse doesnt seem to notice it and pans the wrong way. Like it doenst know my rotation. I dont know how to solve it. This is my rotate/mouse script:
if (Input.GetKey("q"))
{
orientationPanel.transform.Rotate(-Vector3.left * 100f * Time.deltaTime);
cam.transform.Rotate(Vector3.forward * 100f * Time.deltaTime);
}
if (Input.GetKey("e"))
{
orientationPanel.transform.Rotate(Vector3.left * 100f * Time.deltaTime);
cam.transform.Rotate(-Vector3.forward * 100f * Time.deltaTime);
}
if (Input.GetMouseButtonDown(0) && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
Fire();
}
float mouseX = Input.GetAxis("Mouse X");
float mouseY = -Input.GetAxis("Mouse Y");
rotY += mouseX * mouseSensitivity * Time.deltaTime;
rotX += mouseY * mouseSensitivity * Time.deltaTime;
rotX = Mathf.Clamp(rotX, -clampAngle, clampAngle);
rotZ = orientationPanel.transform.rotation.z;
Quaternion localRotation = Quaternion.Euler(rotX, rotY, rotZ);
transform.rotation = localRotation;
Comment
Your answer