*
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class CameraFollowController : MonoBehaviour {
|
||||
|
||||
public Transform target;
|
||||
public float distance = 1.0f;
|
||||
public float height = 1.0f;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
if (target != null) {
|
||||
var forward = target.transform.forward;
|
||||
forward.y = 0;
|
||||
forward.Normalize();
|
||||
transform.position = target.transform.position - forward * distance + Vector3.up * height;
|
||||
transform.LookAt(target.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user