World context object

objects do not exist in a world, so they cannot spawn actors, unless you give them a context actor, so the spawn function knows what world you are talking about. in C++, context actors are required to GetWorld(), but this option may be missing from blueprint, so spawning actors from objects is not recommended.

you might have several worlds at once. for example, in an arena combat game, one player may be watching a killcam replay in a separate world than another player who is in battle. if you wanted, you could spawn actors into the replay world, without spawning them into the combat world, but you would need to pass an actor from the replay world into the context input of the spawn function, or call the spawn function from within an actor that exists in the replay world.

so basically, you should only spawn actors from other actors.

if you want to spawn an item actor from an item object, you should probably keep an array of those objects in an Actor called Inventory. this InventoryActor can get data from its objects and spawn actors into the world, although you could also do that with structs instead of objects, and it would cause less memory overhead.

7 Likes