Can I run functions on build level?

I want to run a function, in editor, or when building the level, to set the default value of a variable on the game mode, or maybe to fill a data table, don’t know what is best, nor what is possible.

To elaborate a little, my game is a vertical scroller, I made an Actor responsible for calling events when the player progress (distance covered at a fixed speed), that events can spawn an enemy or finish the game at desired X location. Currently on begin play, my game mode creates an array of Actors using get all actors of that class, after that, every frame it checks if the player as passed on of that actors, if so, it fires the actors event and removes the actor ref from the array.

But I think checking every frame an array of actors can be demanding, so when creating the array I’ll sort it, based on actors distance relative to the player start, and after that I’ll only need to check the first actor of the array, firing the event if the player passes it, and removing the first actor from the array.

But even with that solution, the part where I get all actors and them sort all of them can be done before the game even starts, but I don’t know how.

I know about Blueprint Editor Utility, and Blueprint Editor Utility widget, but can I use that to set the default value of the array in the Game Mode? Can that array be a read only after the game starts? Using a variable to store imutable data seems wrong, should I use other thing? like a data table?

Also could i do that asynchronous on the firsts seconds of the game?

Obs.: Sorry for my bad english, hope I made it clear. Thank you for the help.

Hello there,
what you could do:
A.1 Create a Structure with a variable of actor class and a Transform
A.2 Create a DataTable from this Structure and populate it with your classes and the Trasnforms
A.3 Inside your GameMode on e.g. BeginPlay get that DataTable and for each row spawn the class with the corresponding transform.
(alternative: If you just have one class you can create and Array of transforms inside the GameMode and use this to spawn your “Checkpoints”)

B.1 Have a Checkpoint class with Tags. For example your first Checkpoint could have a Tag “PlayMusic” another could have “SpawnEnemy” which you could than use to do something.

C.1 Have a multiple “Checkpoint” classes which do different things on e.g. OnBeginOverlap have a SaveFunction or SpawnEnemy etc

You can spawn them inside the GameMode before you assign your player a character. You can place them inside the level beforehand when they have events which trigger when you enter a certain area. You can spawn them inside the LevelBlueprint.