public static void Init_DoTweenPath(this Transform this_wife,Vector3[] WayPoints,float Speed,Ease ease= Ease.InOutSine)
{
//路径点位容器
DG.Tweening.Plugins.Core.PathCore.Path path = new DG.Tweening.Plugins.Core.PathCore.Path(PathType.Linear,WayPoints,10);
var core=this_wife.DOPath(path, Speed,PathMode.Full3D);
//来回移动
core.SetLoops(-1, LoopType.Yoyo);
//前进方向的设置
core.SetLookAt(0.01f,Vector3.forward);
bool lines = false;
core.OnStepComplete(() =>
{
lines = !lines;
if (lines)
{
core.SetLookAt(0.01f,Vector3.back);
}
else
{
core.SetLookAt(0.01f,Vector3.forward);
}
});
}
SetLookAt(0.01f,Vector3.forward) 默认是一直向前,但是我们是来回运动,比如模拟车辆行驶的轨迹,这就需要车辆调头,所有需要调整方向Vector3.back