核心提示:小怪平滑跟随角色的实现代码public class Follow : MonoBehaviour {public GameObject main;Vector3 actuallyward = Vect...
小怪平滑跟随角色的实现代码
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); }