- Home /
How to Rotate Camera around GameObject (Player)
I am in a pickle. Whilest, transform.position = player.position + offsetX; works, or + offsetY; works, the combination of the two do not! Any Suggestions?
 using UnityEngine;
 using System.Collections;
 
 public class Orbit : MonoBehaviour {
     
     public float turnSpeed = 4.0f;
     public Transform player;
     
     public float height = 2f;
     public float distance = 6f;
     
     private Vector3 offsetX;
     private Vector3 offsetY;
 
 
     void Start () {
         
         offsetX = new Vector3 (0, height, distance);
         offsetY = new Vector3 (0, 0, distance);
 
     }
     
     void LateUpdate()
     {
         offsetX = Quaternion.AngleAxis (Input.GetAxis("Mouse X") * turnSpeed, Vector3.up) * offsetX;
         offsetY = Quaternion.AngleAxis (Input.GetAxis("Mouse Y") * turnSpeed, Vector3.right) * offsetY;
         transform.position = player.position + offsetX + offsetY;
         transform.LookAt(player.position);
 
     }
 }
 
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                