Spawning actor not working on mobile

Hello,

I have an array of blueprints in an actor that is functioning as a manager. This actor has to spawn a blueprint from this array as an actor on the screen while the game is running.

This works perfectly fine when playing in the editor. But when I test the game on mobile the actor is not showing up.

When I try it from the level blueprint (spawning the actor during tick) it is working fine also on mobile. But I want to have this working in code, and it is way to devious to call this blueprint from code to spawn the actor and send it back to code again. It should just work fine from code!

Here is the code for spawning the actor:

UClass* WPActor = aAvailableWPActors[rNmb]->GeneratedClass;
AWPActor* A = World->SpawnActor<AWPActor>(WPActor);			
A->SetActorLocation(vSpawnLoc);

Why is this working fine playing in editor but not when building to mobile (Android)???

1 Like

Hello, SoulRyder

I am sorry to hear about your problem.
To fix it, please try spawning the Actor with Transform parameters:

AWPActor* A = World->SpawnActor<AWPActor>(WPActor, Rotation, Location);    

Also, please make sure that World exists at the moment of spawning. For this, you can call it from BeginPlay() , PostInitializeComponents() or other functions, that are executed later (so that World pointer is valid).

Hope this helped!

Cheers!