Daily Unreal Column #63 - Actor Spawn Parameters
Dynamically spawning different AActor subclasses is nothing unusual. Its a bread and butter of making a game in Unreal Engine. But have you ever explored the spawn parameters?
Usually when we are spawning an actor we stick with the simplest way of doing so, which look something like this:
GetWorld()->SpawnActor<AActor>(ActorClass, Location, Rotation);
Nothing wrong with doing it this way, however, it is worth remembering that there is another, optional, parameter of type FActorSpawnParameters.
If you take a look at the available properties you would be surprised how many useful things you can achieve simply by filling in these properties.
For example:
Template — actor that should be used as template for the new actor. The new actor is going to be initialized using property values of the template actor
bHideFromSceneOutliner — when set to true, the spawned actor will not appear in the scene outliner
SpawnCollisionHandlingOverride — allows to to override spawn collision handling, meaning you can force this actor to always spawn regardless of the spawn transform
I highly encourage you to go and explore the remaining properties of this struct.