Get All Actors of Class - What is the order in which the resulting Array is built?

I have created an AI Character which upon begin play, it finds the pre determined path that i have laid out in the level, the path is defined by an actor blueprint i made which contains an Enemy ID this Enemy ID is checked against the AI Enemy’s ID for each actor of that class, if true that actors location is stored to a Vector Array.

It works flawlessly in terms of its mechanic but i have just encountered a problem where the Enemy AI does not follow the path exactly. I was confident that the Array Result from Get all Actors of Class was built by getting the actors based on their position in the world outliner i.e. the path nodes i placed first would be the next path the AI would go to. Evidently this is not true, does anyone know the specific order in which the get all actors of class creates the array?

It works flawlessly for paths of 3-4 nodes though this is the largest path i have created for the character and it contains around 30 path nodes.

1 Like

Im assuming the Engine orders the Array based on how it instantiated each class. Eitherway I would never rely on GetAllActorsofClass to return an array that is ordered how i think it will be ordered. For a waypoint type setup you should really be ordering it yourself to avoid situations like this.

Each node in your path should store a reference to the previous node at least (or even just a int that defines its position in the path). This way you can always traverse the path in intended order.