hello, first sorry for my bad english …
i want to rotate camera around object at X and Y axis only, how could i prevent Z axis rotation and keep it at zero ?
here is my code
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public GameObject Target;
public float rotateSpeed = 100f;
public Vector3 offside;
void Start () {
offside = Target.transform.position;
transform.LookAt (offside);
}
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.DownArrow))
transform.RotateAround (offside, Vector3.left, rotateSpeed * Time.deltaTime);
else if (Input.GetKey (KeyCode.UpArrow))
transform.RotateAround (offside, Vector3.left, -rotateSpeed * Time.deltaTime);
else if (Input.GetKey (KeyCode.LeftArrow))
transform.RotateAround (offside, Vector3.up, -rotateSpeed * Time.deltaTime);
else if (Input.GetKey (KeyCode.RightArrow))
transform.RotateAround (offside, Vector3.up, rotateSpeed * Time.deltaTime);
}
}
please help me with example, i still noob …