using UnityEngine;
using System.Collections;
public class CameraFollow : MonoBehaviour {
public Transform target;
// The distance in the x-z plane to the target
public float distance = 10.0f;
// the height we want the camera to be above the target
public float height = 5.0f;
void LateUpdate () {
// Early out if we don't have a target
if (!target)
return;
// Set the position of the camera on the x-z plane to:
// distance meters behind the target
transform.position = target.position;
transform.position -= Vector3.forward * distance;
transform.position = new Vector3(transform.position.x,transform.position.y + height,
transform.position.z);
// Always look at the target
// transform.LookAt (target);
}
}
第三人视角,摄像机跟随代码
最新推荐文章于 2023-07-09 13:22:06 发布