How can I set properties of a spawned actor before component signatures (like OnBeginComponentOverlap) are called?

The Problem

I need to set properties of a spawned actor before component signature callbacks are triggered - on both the spawned actor and existing world actors.

The Setup

I have a Minion class that extends Character. It has a SphereComponent with OnBegin/OnEnd overlap delegates to keep track of other enemy minions when they’re in range of the minion. There’s also a property that identifies the owner of the minion that is used to determine which minions are enemies of the owner. The component and signatures are created in Minion’s constructor. The identifier is set manually from whichever class is spawning the Minion.

Example of the problem

I’ll spawn a Minion from another class (GetWorld->SpawnActor), the constructor will execute, but it will also immediately trigger Overlapping events on existing nearby actors, as well as the spawned actor, before I can set the Minion’s owner identifier.

Possible Resolutions

I could simply not rely on the dynamic properties I need to set (collect all minions and evaluate which to attack later), or create subclasses for each minion of each team, but I think both solutions are inefficient in the long run. I’m hoping there’s some construction hook I’m overlooking, or I’d like to suggest the broadcasting of initial component signatures be moved to execute just prior to BeginPlay(), which will allow the class that spawned the actor time to initialize and set other properties of the actor.

You can avoid overlap events by setting NoCollision on your sphere components before binding the begin overlap delegate functions. Then later, in your begin play or whenever you are ready to have the events start firing, set the collision behaviour you want then. I think that should do.

I resolved this by setting AActor::SetActorEnableCollision to false in my actor’s constructor and then later setting it to true (via the spawner class) once I’ve set the properties I need.

As BadderThanBad suggests, setting UPrimitiveComponent::SetCollisionEnabled to NoCollision prevents the overlap signatures of that component from triggering, however other components on other actors will still inherit overlap events from the component (based on collision response).

I believe an alternative is manually setting collision response channels to “Ignore” using UPrimitiveComponent::SetCollisionResponseToChannel.