public Transform target;
public float distance ;
public float targetHeight;
public float PitchAngle;
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-PitchAngle, y, 0);
transform.rotation = rotation;
// POSITION CAMERA:
Vector3 position = target.position - (rotation * Vector3.forward * distance + new Vector3(0,-targetHeight,0));
transform.position = position;
}
Unity摄像机跟随Target快速位移和旋转
最新推荐文章于 2024-07-29 21:59:26 发布