A
A
Andrew Far2017-04-19 19:31:29
Unity
Andrew Far, 2017-04-19 19:31:29

How to build a path from point A to point B visually in Unity3D?

Conventionally, there are two objects, let's say two cars. Machine I has a target machine II, it is necessary to visualize the path from machine I to machine II, and not just a ray of the Debug.DrawLine type, but specifically, it was possible to create an object and scale it from object A to object B ... is there any tool? Maybe some video lesson has such content or something else? Help me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2017-04-20
@StAndrewOm

The easiest way is to use the LineRenderer component .
If its capabilities are not enough, then you can instantiate prefabs at each point in the path:

private GameObject waypointPrefab;

private void DrawPath(List<Vector3> path)
{
    foreach (var position in path)
    {
        Instantiate(waypointPrefab, position, Quaternion.identity);
    }
}

If desired, you can rotate them towards the next point. You will most likely also need a pool for the objects you instantiate.
If you need a visualization that is inseparable, but more detailed than LineRenderer can do, then you can build a mesh of the desired shape at runtime. There are good tutorials on the topic here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question