Problem with the array of customized class in blueprint

Hello,
I’m focusing the AI part, I intend to use multiple NPCs, so each targetpoint have an array in which I will store the next targetpoint numbers of all of the NPCs. the element of this array is an actor I create called “BP_APBotWayPointInfo”. There are two integer variables in the actor: “botID” and “NextWayPointNumber”, as shown following:

Then I create a targetpoint called “BP_AIWayPoint”, in which I create an array called “BotsInfo”. The variable type of this array is “BP_AIBotWayPointInfo” class, which is I create just before. As shown following:

I wish to set default values for all the elements of the array before the gameplay, however, I don’t know how to do it ? As shown in the image above, I have created an element for the array, but I cannot find the place to set the values(“botID” and “NextWayPointNumber”) in this element.
I’m not sure if I describe my problem clearly, wish someone could help, thanks !

Hei!

It seems the elements in BotsInfo are of the type BP_AIBotWayPointInfo class, not an instance of BP_AIBotWayPointInfo. Basically this means the elements allow you to select one of your classes that derive from BP_AIBotWayPointInfo. This can be handy sometimes, but it’s probably not what you want now. I guess you want a reference to an existing instance of BP_AIBotWayPointInfo. You can change the array as follows:

122944-array_type.png

(Remember to compile after changing the type.)

Now, one more thing to keep in mind is that your instances are only referenced, thus they must already exist somewhere in your scene. I can see your BP_AIBotWayPointInfo derives from AActor, so I guess they are some sort of objects in your scene? Those can then be placed where-ever you like and then, once they exist, you can select them in the array.

If you didn’t mean to have BP_AIBotWayPointInfo in your scene, maybe you didn’t want it to be an actor? If you only want a single set of properties you could create a new struct:

122945-new_struct.png

The cool thing about a struct is that they can “live” in the array, no need to reference. So your array can be a simple collection of sets of properties that you can edit in place:

122946-struct_array.png

Maybe that’s what what you are looking for? I hope this info helps, one way or another!

Thanks very much ! Struct is exactly what I want ! As you said, I don’t want th array elements shown in the scene, so now I understand actor is not good choice for me. I’m new of using blueprint, thank you very much for your help !

Thanks for the comments, it feels good to know I could be helpful :slight_smile: