IMHOTEP Framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
PanToTarget.cs
1 using UnityEngine;
2 using System.Collections;
3 
4 public class PanToTarget : MonoBehaviour {
5 
6  public GameObject target;
7 
8 
9  // Use this for initialization
10  void Start () {
11 
12  }
13 
14  // Update is called once per frame
15  void Update () {
16  Vector3 diff = target.transform.position - transform.position;
17  float pan = Mathf.Atan2 (diff.x, diff.z);
18  transform.rotation = Quaternion.AngleAxis (pan*180f/Mathf.PI + 180, Vector3.up);
19  }
20 }