# Make actor follow points to reach destination

**URL:** <https://forums.unrealengine.com/t/make-actor-follow-points-to-reach-destination/1885338>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Blueprint\
**Created:** [June 2, 2024, 12:36pm UTC](https://forums.unrealengine.com/t/make-actor-follow-points-to-reach-destination/1885338 "2024-06-02T12:36:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![GernalIeal](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gernalieal/32/1182908_2.png) [@GernalIeal](https://forums.unrealengine.com/u/GernalIeal)\
**Post date:** [June 2, 2024, 12:36pm UTC](https://forums.unrealengine.com/t/make-actor-follow-points-to-reach-destination/1885338/1 "2024-06-02T12:36:06Z")

</div>

Here is an illustration of what im looking for:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/0/d/50dbe9470aee967159c6f6d2b521f26d0ba2bbd8.png)

Say I have an actor who needs to get from point 1, to point 4 but they MUST follow points 2 and 3 to get there. How i do?

Currently I have a road system where you click to place road points down and they connect to the previously placed point.

All points are aware of their immediate connections like so:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/9/7f9f3f6189343892b764af12283958d547e10cbd.png)

So back to the main question. How do I tell Bob he must follow the connected points to reach his next location? I imagine its kinda like A\* Pathfinding, but with only certain points Bob can go.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [June 2, 2024, 1:03pm UTC](https://forums.unrealengine.com/t/make-actor-follow-points-to-reach-destination/1885338/2 "2024-06-02T13:03:54Z")

</div>

To plan those paths manually its not complicated code:  
Make struct that is:

- something that identifies path, like starting point and ending point. Let it be 2 integers
- then array of integers for actual path

When actor needs to go from A to B, you select one of predefined paths. So you get from array in struct integers that represent points. Then read next point, gets its world location and follow.

That is for selecting and playing path to follow.

Now how to make points:

- create actor that is “nav point”, add to it some marker like red mesh or billboard or just arrow component
- that actor should have exposed to editor variable, that is integer index, sadly you should set that index manually, constructor script does not guarantee they (index numbers) will not change.
- so now you have nav point actors, each has \>UNIQUE\< index. You can set up path by adding indexes to array in struct.

Next step would be combining 2 different paths to move from A to B then B to C.

And next next step is finding optimal (shortest) path. But that i think needs some graphs traversing etc, so probably C++.

---

<div class="post-metadata">

**Author:** ![GernalIeal](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gernalieal/32/1182908_2.png) [@GernalIeal](https://forums.unrealengine.com/u/GernalIeal)\
**Post date:** [June 2, 2024, 1:24pm UTC](https://forums.unrealengine.com/t/make-actor-follow-points-to-reach-destination/1885338/3 "2024-06-02T13:24:43Z")

</div>

So I figured out a way which seems really bad for performance but without C++ i can’t think of another way.

> Starting at the final point \> Does that point connect to Bob’s current point?
> 
> Yes \> Move Bob to final location
> 
> No \> Check every point connected to the final point and ask does that point connect to Bob’s current point?
> 
> Yes \> Move to that point, then repeat until at final location
> 
> No \> Repeat above step until one a point does connect, otherwise there is no path to the final location

I think that is a logical way of thinking about it and will test it now.

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [June 2, 2024, 1:47pm UTC](https://forums.unrealengine.com/t/make-actor-follow-points-to-reach-destination/1885338/4 "2024-06-02T13:47:05Z")

</div>

If those points do not change in RUNTIME you should make/calculate paths only once at begin play.  
However if level is premade (ie. not proceduraly generated) you can create optimal paths manually in editor.

---

<div class="post-metadata">

**Author:** ![GernalIeal](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gernalieal/32/1182908_2.png) [@GernalIeal](https://forums.unrealengine.com/u/GernalIeal)\
**Post date:** [June 2, 2024, 1:53pm UTC](https://forums.unrealengine.com/t/make-actor-follow-points-to-reach-destination/1885338/5 "2024-06-02T13:53:49Z")

</div>

Its a city builder game, the roads are made at the player discretion. In testing with 50-100 cars it doesnt seem that theres much lag. Will see how it performs with more later.

---

<div class="post-metadata">

**Author:** ![BugSwat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BugSwat](https://forums.unrealengine.com/u/BugSwat)\
**Post date:** [June 2, 2024, 2:33pm UTC](https://forums.unrealengine.com/t/make-actor-follow-points-to-reach-destination/1885338/6 "2024-06-02T14:33:23Z")

</div>

Just to throw in an idea:

- Put “NavMeshBoundsVolume” where you want the path to be
- Use “AI Move To” with the variant that uses NavMesh.

---

<div class="post-metadata">

**Author:** ![baobao4435](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/baobao4435/32/950790_2.png) [@baobao4435](https://forums.unrealengine.com/u/baobao4435)\
**Post date:** [June 2, 2024, 2:47pm UTC](https://forums.unrealengine.com/t/make-actor-follow-points-to-reach-destination/1885338/7 "2024-06-02T14:47:33Z")

</div>

How about a spline?

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [June 2, 2024, 7:53pm UTC](https://forums.unrealengine.com/t/make-actor-follow-points-to-reach-destination/1885338/8 "2024-06-02T19:53:46Z")

</div>

Oh for city build game, you definitely need C++ to create navigation.

Also depending on how many cars actors you want on street, you may need to optimize it heavily. That means you fake traffic not simulate it. And best would be something like niagara, to move cars on street so it looks like traffic.

I am working on game that has lots of actors moving but in space.  
What i found out (and what failed):

- using niagara and instanced static meshes, Tiny instanced static meshes look bad. Well maybe that can work for cars. But we were able to move around 20000 of such meshes, in c++ on tight loop.
- using niagara and particles (transparent ones so overdraw was heavy), that got down to 5000 objects
- now we are using actors with single emmiter each, we got down too 2000.

Anyway if this is for cars that are visual only (not gameplay), just fake traffic do not bother with paths navigating. Else expect around 1000 maximum.

And there is whole MassEntity plugin in matrix city demo. Look there.

And describe scope of game whet you need this pathing for.
