Quantcast
Channel: Questions in topic: "around"
Viewing all articles
Browse latest Browse all 101

How to Rotate Camera around GameObject (Player)

$
0
0
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); } }

Viewing all articles
Browse latest Browse all 101

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>