how to Rotate Camera around GameObject with mouse, where up is always up?
I made myself familiar with RotateAround() but I have an issue when using it together with my mouse to move a camera around another GameObject. When the Camera gets behind the object the controls for moving up and down switch around (kind of):
http://gfycat.com/AgileBigJellyfish
I don't wan't that movement to change. Also I want the camera to stop moving up/down if it's at the top or the bottom of the target GameObject.
My current script:
public float speed;
public GameObject target;
void Update () {
if (Input.GetMouseButton(0)) {
transform.RotateAround(
target.transform.position,
target.transform.up,
Input.GetAxis("Mouse X") * speed);
transform.RotateAround(
target.transform.position,
target.transform.right,
Input.GetAxis("Mouse Y") * speed);
}
transform.LookAt(target.transform, target.transform.up);
}
Your answer
Follow this Question
Related Questions
Cant figure out simple camera orbit 0 Answers
How to limit/Clamp RotateAround for camera movement? 0 Answers
Rotate camera around pivot not working on certain angles 0 Answers
Why aint my gameObject(the one i aplied the script) moving? 1 Answer
Rotating Camera around Player's X-axis while rotating Player around its Y-axis (using mouse input) 0 Answers