Y
Y
yraiv2022-01-18 21:36:25
Unity
yraiv, 2022-01-18 21:36:25

How to move around given points in unity3d?

How can you move to given points? I have an array of different points on the map and the AI ​​speed is set, it is necessary that it runs from the first to the second point, then to the third and so on. How can this be done? I found an implementation for this idea, but more smooth, I would like it not to be superfluous and just have a sharp 90-degree turn, etc., if he has to turn

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GFX Data, 2022-01-18
@ShockWave2048

There is such a DOTween asset - https://assetstore.unity.com/packages/tools/animat...

List<Vector3> points; // список точек
Transform t; // двигающийся объект
float speed = 5f;
var seq = DOTween.Sequence();
foreach (var p in points)
{
    seq.Append(t.DOLookAt(p), 1f); // поворачиваем на точку
    seq.Append(t.DOMove(p, speed)); // двигаем в точку
    seq.SetLoops(-1, LoopType.Yoyo); // двигаемся без конца
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question