ilyas kose
ilyas kose

Reputation: 85

DoTween DoPath's speed between waypoints

I have a question about DoPath's speeds between waypoints. I want constant speed from start to end but i couldn't achieve that. But speed changing between waypoints.

I couln't find solution for my problem.

Vector3 firstPoint = from+new Vector3(5f,5f,0);

pathList.Add(from);
pathList.Add(firstPoint);
pathList.Add(to);


Vector3[] pathArr = pathList.ToArray();

GameObject trail = Instantiate(config.fireWork, from, Quaternion.identity);
       trail.transform.DOPath(pathArr,3,PathType.CatmullRom,PathMode.TopDown2D).SetEase(Ease.Linear).SetLookAt(0.01f).SetDelay(1f);

https://gfycat.com/highunknowngentoopenguin

I want constant speed from start to end.

Upvotes: 4

Views: 13787

Answers (3)

T M
T M

Reputation: 3315

If you put .SetSpeedBased(true) the duration will represent the number of units the tween moves x second.

P.S. You can also set .SetLoops(-1) execution will loop on path.

Upvotes: 3

ilyas kose
ilyas kose

Reputation: 85

I solved problem, there is nothing wrong with DoPath function. It is about my from and to vectors. My game is 2D but vectors has very high values of Z. So missile seems very fast in 2D. I changed Z values of from and to values problem solved. Thanks @Demigiant for help.

Upvotes: 1

Iggy
Iggy

Reputation: 4888

Looks like it only takes in the duration of the tween.

You may have to use the generic way: DOTween.To(...).

Get the distance between the current points and divide it by your movement speed.

Upvotes: 3

Related Questions