I slap this script to the camera which is a child object in an invisible sphere. It works really nicely as a free roaming camera script but there is one issue: using Q and E for rotation doesn't add up with the 'free look while holding middle mouse button' so it flips to a straight rotation when you click fire3 I seem to be lacking the skill to figure this out... Everything that involves rotating things seems to paralyze my mind. Anybody who can help out? Code (CSharp): using UnityEngine; using System.Collections; public class Camera : MonoBehaviour { public float RotationSpeed = 60.0f; public float KeySpeed = 7.0f; public float ScrollSpeed = 50.0f; public float MouseSensitivity = 4.0f; private float yaw = 0.0f; private float pitch = 0.0f; float minHeight = 200f; void Update() { Vector3 currentPosition = transform.parent.position; float height = transform.parent.position.y; // WASD keyboard input if (Input.GetKey(KeyCode.W)) transform.parent.Translate(Vector3.forward * Time.deltaTime * KeySpeed); if (Input.GetKey(KeyCode.S)) transform.parent.Translate(Vector3.back * Time.deltaTime * KeySpeed); if (Input.GetKey(KeyCode.A)) transform.parent.Translate(Vector3.left * Time.deltaTime * KeySpeed); if (Input.GetKey(KeyCode.D)) transform.parent.Translate(Vector3.right * Time.deltaTime * KeySpeed); // QE rotation if (Input.GetKey(KeyCode.Q)) transform.parent.RotateAround(currentPosition, Vector3.up, (-RotationSpeed * Time.deltaTime)); if (Input.GetKey(KeyCode.E)) transform.parent.RotateAround(currentPosition, Vector3.up, (RotationSpeed * Time.deltaTime)); // scrollwheel to lower or raise camera if (Input.GetAxis("Mouse ScrollWheel") < 0) transform.parent.Translate(Vector3.up * Time.deltaTime * ScrollSpeed); if (Input.GetAxis("Mouse ScrollWheel") > 0) transform.parent.Translate(Vector3.down * Time.deltaTime * ScrollSpeed); // Free look while holding middle button if (Input.GetButton("Fire3")) { yaw += MouseSensitivity * Input.GetAxis("Mouse X"); pitch -= MouseSensitivity * Input.GetAxis("Mouse Y"); transform.parent.eulerAngles = new Vector3(pitch, yaw, 0.0f); } if(height < minHeight) { transform.parent.position = new Vector3 (transform.parent.position.x, minHeight, transform.parent.position.z); } } }
solved it, update transform.parent.eulerAngles.y when Fire3 is clicked: Code (CSharp): // Free look while holding middle button if (Input.GetButtonDown("Fire3")) yaw = transform.parent.eulerAngles.y; if (Input.GetButton("Fire3")) { yaw += MouseSensitivity * Input.GetAxis("Mouse X"); pitch -= MouseSensitivity * Input.GetAxis("Mouse Y"); transform.parent.eulerAngles = new Vector3(pitch, yaw, 0.0f); print(yaw); } Thanks self!