https://www.bilibili.com/video/BV1ff4y197Tx/
public class FollowTarget : MonoBehaviour
{
public Transform player;
private Vector3 offset;
public float smooth = 3;
// Start is called before the first frame update
void Start()
{
offset = transform.position - player.position;
}
// Update is called once per frame
void FixedUpdate()
{
Vector3 targetPosition = player.position + player.TransformDirection(offset);
transform.position = Vector3.Lerp(transform.position, targetPosition, Time.fixedDeltaTime * smooth);
transform.LookAt(player);
}
}
standard assets
(提取码:60i9)