Hey everyone! So I though of modular road construction where actors could move on the road using nodes placed at the beginning and the end of the road. Could someone explain to me what would be the best way of creating simple AI system which would move actor through the nodes? I’ve seen function Simple Move To which works perfectly but I’m not sure how to add multiple target points so the actor would move to first node, then the second one, then third one etc…
This is a simple drawing I’ve made which would describe how the roads would work with notes (green dots):
I would create road segments like straight roads, intersections and other. They all would use just simple movement between nodes.
If you are comfortable using the Simple Move to then your already halfway there. What your missing is just a list of your points that you want to walk thru and an index for which point you are currently going to. You can make an array of vector3 variables, one for each point you want them to go to, and an integer which holds where in the array you are currently moving to. Have your AI move to the first point in the array, index 0, and when it gets there have it
1.) check if the index it is currently at is the last one and if so set the index back to 0 and if not set the index to +1.
2.) go back to the beginning when you did your move to and have it go to the new location in your array using the new updated index.
This is a pretty simple way to accomplish what you would like using the simple move to that you mentioned.
This can be expanded further for example by using a custom BP object that you place in your level as each waypoint then you expose the array you made earlier and fill it with those waypoints so you could interactively build the path in the editor.
Thank you very much for your help Matthew! Okay so for the first step, set all the nodes and save their location into an array. Alright.
Now I have one more concern. If I have for example start of the actor at on part of the map, and it needs to go to a node on the other part of the map. It will have to go through a lot of nodes to achieve this, where some of the nodes are placed on the intersection so it will need to decide which is the best part to go so I have to ask how would I set up a pathfinding BP so it can know where to go? I know I can use navmesh for pathfinding but I can’t use it here because of the array of nodes if I’m right.