main class for unreal project?

So I’m pretty new to UE4 and I’m looking to implement flocking behaviour. To do that I’m thinking of having a main class that spawns all the actors for the flock in random positions in the map with a for loop at the start of the game. And also store them in a global array so that i can perform operations on all of them. Pretty much what this guy is doing with level.cs at 4:01

except he’s using Unity. However i can’t seem to find an equivilent to level.cs (assuming this is the main class in Unity?) that this guy is working with, and all tutorials i’ve done for UE4 don’t seem to bring up a main class for the UE4 projects. Is there such an equivilent to a main class in UE4?

Or atleast how would i go about spawning 50-100 actors (of the same actor class) and store them in an array upon game start? I’ve tried googling this for a while now and have not found anything helpful…

I would create this as from a new class based on AActor.
Then you can just spawn in in to what ever level you want with GetWorld()->SpawnActor(bla) or the Blueprint equivalent.

The spawning of your flock should go in your AGameModeBase child. The actor that is flocking should probably be a APawn or ACharacter depending. For example, AFlockGameMode::StartPlay() would be an acceptable place to spawn your actors (though there are many others)…




void AFlockGameMode::StartPlay()
{
    Super::StartPlay();
    for (int32 i=0; i < NO_OF_PAWNS)
    {
        FVector SpawnLocation = GetFlockPawnSpawnLocation();
        FActorSpawnParameters SP;

        SP.ObjectFlags |= RF_Transient;
        SP.Owner = this;

        AFlockPawn* P = GetWorld()->SpawnActor<AFlockPawn>(AFlockPawn::StaticClass(), SP);
        if (P != nullptr)
        {
            MyFlockPawnStorageArray.Add(P);
        }
    }
}