21 lines
510 B
C#
21 lines
510 B
C#
using UnityEngine;
|
|
|
|
public class FollowPlayer : MonoBehaviour
|
|
{
|
|
public Transform Player;
|
|
|
|
public Vector3 offset;
|
|
|
|
public float smoothSpeed=0.125f;
|
|
|
|
// Update is called once per frame
|
|
void FixedUpdate()
|
|
{
|
|
Vector3 aim = Player.position + offset;
|
|
Vector3 smooth = Vector3.Lerp(transform.position, aim, smoothSpeed);
|
|
//transform.position = new Vector3(smooth.x, aim.y, aim.z);
|
|
transform.position = smooth;
|
|
transform.LookAt(Player);
|
|
}
|
|
}
|