public Transform target;
public float distance ;
public float targetHeight;
private float x = 0.0f;
private float y = 0.0f;
void Start () {
var angles = transform.eulerAngles;
x = angles.x;
y = angles.y;
}
void LateUpdate ()
{
if(!target)
return;
y = target.eulerAngles.y;
// ROTATE CAMERA:
Quaternion rotation = Quaternion.Euler(x, y, 0);
transform.rotation = rotation;
// POSITION CAMERA:
Vector3 position = target.position - (rotation * Vector3.forward * distance + new Vector3(0,-targetHeight,0));
transform.position = position;
}
http://blog.csdn.net/tanmengwen/article/details/7995932
Unity摄像机旋转和位移跟随
最新推荐文章于 2024-07-11 14:49:59 发布