Spawning Actors from an Array Causes a Crash

Array is not a fault, looking on stackdump:

UE4Editor_SpaceInvaders_5426_Win64_DebugGame!AEnShips::mySpawn() [c:\users\\onedrive\documents\unreal projects\spaceinvaders\source\spaceinvaders\enships.cpp:63]
 UE4Editor_SpaceInvaders_5426_Win64_DebugGame!AEnShips::BeginPlay() [c:\users\\onedrive\documents\unreal projects\spaceinvaders\source\spaceinvaders\enships.cpp:27]

Your code crashes in mySpawn, i susspecting here:

   a->x = x;
    a->y = y;

If ship fail to spawn it will be null so if you call something from it will crash in that case

So do this:

if(a) {
     a->x = x;
     a->y = y;
     a->SetActorLocation(pos);
}

Now if spawn fail it should not crash and in logs you can check why they didn’t spawn SpawnActor prints reason in all cases

Other reason why you could get crash is wrong type casts incompatible with AEnemyShip*