How to spawn actors without creating references?

Here’s better solution:

On game mode, just get actor with tag and communicate through interface.


This way the game mode only references the interface.

To keep the Spawner actor clean, abstract a database of soft-referenced actors to an uobject:

The Spawner Actor can create the uobject only when needed for spawning, seen here:

Reference view of the SpawnDataBase object:

It is holding an array of soft-referenced actors and successfully not generating any hard-references.

It looks like this is a cleaner solution than what I wrote above that accomplishes the goal. The game mode does not force anything to load, it uses a single interface call to communicate that some actors should be spawned, and the spawner actor also does not force anything to load until I explicitly tell it to.

Why use the Uobject though? Why not just put the soft-references into the spawner actor?
The reason is because if I do that, the spawner actor is then creating hard references. I am not sure why, but if I use soft references in a uobject, it works like I’d expect. If I put them in an actor, it still creates hard references.

This must indicate something about actors - something over my head. But at least this solution works and it is not too abstract or complicated to manage.

4 Likes