how to call a function from c++ class that is not an Actor

hello, i have made a c++ h. file and made a struct to let it be accessible in all the games classes, that is working nice.

now i’m trying to create an array of that struct and call a function at the begin of the game to fill the struct array with some default values, but i have tried to override BeginPlay on the c++ class but the compiler sent me an error that says it cannot override the function (i’m assuming that the problem is because my c++ .h file is no an actor class)

how to call a function from c++ or blueprints to let the array be filled with data ? also this c++ class is not an object, it can’t be placed on the map.

any help will be very useful.

thanks in advance for all your help.

sorry for the bump, but i still need help to figure this out.

If you want your class to be initialized on the start of the game(mode), you can simply write a function (override) BeginPlay and EndPlay on your gamemode class, then initialize/deinitialize your class out of this functions.

You have to instantiate the class first. It doesn’t call BeginPlay() because it isn’t spawned in a world, unlike Actors which are specifically for existing in a world.

Instantiate your class from somewhere (like in the GameMode) and then invoke whatever function you like from said class.