mycj_demo/mycj/Assets/Script/npcMove.cs

37 lines
846 B
C#
Raw Normal View History

2024-12-02 09:37:47 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class npcMove : MonoBehaviour
{
public List<Transform> path=new List<Transform>();
public float moveNeedTimer;
2024-12-02 23:38:32 +08:00
2024-12-02 09:37:47 +08:00
public void Init(List<Transform> path,float moveNeedTimer)
{
this.path = path;
this.moveNeedTimer = moveNeedTimer;
// <20><>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ Vector3 <20><><EFBFBD><EFBFBD>
Vector3[] pathPoints = new Vector3[this.path.Count];
for (int i = 0; i < path.Count; i++)
{
pathPoints[i] = path[i].position;
}
// ʹ<><CAB9> DOPath <20><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><E3A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>
2024-12-02 23:38:32 +08:00
this.transform.DOPath(pathPoints, moveNeedTimer, PathType.Linear)
.SetOptions(false) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת
.SetEase(Ease.InOutSine)
.WaitForCompletion();
2024-12-02 09:37:47 +08:00
}
2024-12-02 23:38:32 +08:00
2024-12-02 09:37:47 +08:00
}