Make AI follow an array of objects

I’m making an Car AI and now I need a way to make it go through an array of the same object (target point in that case), however, it will only go to the last point inserted in the level, even if in the Array Vector it does show the position for each point.

When you say “follow an array of objects” do you mean you want the car to go to a point, and then the next one and then the next one until it reaches the last point? Or what do you mean exactly?

Also why are you repeating the code you have in the construction script in the Procurar o alvo comment block?

One thing I can tell you is that those connection lines look somewhat troublesome, and the execution lines are all over the place, can’t really tell what’s going on in your script.

It’s to go to a point and then to the next ones as you said.

Sorry about my printscreen, its because the code is rather large, but the part abocve the Get All Actors in the second image is for the car movement.

I repeated because I’m really stuck at what I should do, in order for the Array to store the Target Points in the level, I had to make it in a fuction instead of the Event Graph.

The Get All Actors from the car itself is used to get after the Target Point using the Sphere Raycast, the Get All Actors from the Construction Func is to get the Target Point position and store it into the AlvoArray

I can’t quite see enough in your screenshots but you should be able to use the “Get” function for each value of the array. For the first point, you would Get 0. After that is reached by the car, you would Get 1. Repeat until you hit the last array index and you would then you start back at 0.

Here is the full BP for the Car

Procurar o Alvo means Find the Target in PT-BR

So starting with the Event Begin, the For Each Loop you have is cycling through all the target points immediately in one tick, resulting in the last one being used. You will need to have your code manually cycle to the next point one the first point is reached.

Interesting, how I could make an approach? Even if I switch to event tick it will game the same result.

I did learn about the Array storing each object of the type with this project of following a spline (but inserted on the same BP as the model)

It also does make the use of For Loop and the index.

Oh, I thinking I’m getting the way, switch the loop for an get, althrough I have to specify the index number, it does go to the targetpoint of the array number

Got it guys, just made the same the same health formula applied to the Index and now I have the car following the target.

Thanks everyone, if you are wondering how to do it, use an event overlap begin on your player controlled pawn and node it to Array Indice (array index)

BTW, is there a way to reset the loop?

At your branch when you change the index, I would use the function Get Last Index and connect it to the array. If your integer is greater than the Last Index in the array, you set the index integer to 0 to restart the loop.

I created an array of the actor class and inserted into a Length node to give me back an simple variable return of the value, it did work too.

Update: After thinking everything was OK, the cars started to either attemp to make the inverse path after playing a second time in simulation, or even trying to go to the second item in the array in the Standalone play.

I’m wondering if there is still an issue with the get actor