When can I create a world and spawn an actor?

I’m porting a plugin module. It is an audio plugin. On module load it is trying to create a singleton instance of a uactorcomoponent that it uses both in editor and in gameplay. The component is an audio emitter component.

In edit mode, this singleton audio emitter is used to audition sounds.

In gameplay mode it is used as the “default 2d emitter”. The emitter you play sounds on when you want them to play in stereo with no 3d positioning.

In StartupModule I’ve tried to…

  1. New up an instance of my UAudioEmitterCom. Crash.
  2. Call UWorld::CreateWorld(EWorldType::None, false, FName(“Default2dEmitterWorld”));. Crash.

Any have any ideas? Maybe an example of some other source code I could use for inspiration?


You likely don’t want to create your own World object (unless, you absolutely don’t want your emitters in the same world as other objects). Either way, you want to wait till OnBeginPlay is called most likely as at that point the World has been created and it’s safe to begin spawning actors.

Looks like I might just have needed to do this…
mMy3dEmitter = NewObject<UAudioEmitterCom();

I am starting to look at UGameInstance as well.

I’m making progress, but still not there. What I’ve done is derive my own class from AActor. I’ll call it my AEmitterActor. In its constructor it calls…
mAudioEmitter = NewObject<UAudioEmitterCom>();

It overrides ShouldTickIfViewportsOnly and returns true.

In my module’s startup function I do…
mGlobal2dEmitter = NewObject<AEmitterActor>();

None of that crashes, but my actor never gets ticked.