相机总是在角色背后distanceAway距离处,且在角色头顶上方distanceUp的高度上
public Transform player;
public float distanceUp = 2f;
public float distanceAway = 5f;
public float smooth = 1f;
private Vector3 targetPos;
void Awake()
{
player = GameObject.FindGameObjectWithTag("Player").transform;
}
void LateUpdate()
{
targetPos = player.position + distanceUp * Vector3.up - player.forward * distanceAway;
transform.position = Vector3.Lerp(transform.position, targetPos, Time.deltaTime * 5f);
transform.LookAt(player);
}