小怪平滑跟随角色

public class Follow : MonoBehaviour {


    public GameObject main;


    Vector3 actuallyward = Vector3.forward;


    float speed = 0.3f;


    private void Update()
    {//向量a
        Vector3 dir = (main.transform.position - gameObject.transform.position).normalized;

        actuallyward = Vector3.Lerp(actuallyward,dir,0.2f);


        gameObject.transform.Translate(actuallyward * speed); 
    }

相关文章: