How can I get collision events when I spawn an actor?

Hello, I’m having an issue figuring out how to generate overlap events when I spawn actors on other actors.

In my game, I’m spawning spells in the world. I keep a running list of the objects within the collision area of spells by adding them when I receive a NotifyActorBeginOverlap() event and remove them I receive a NotifiyActorEndOverlap() event. For the most part, this has worked pretty well and given me what I want.

My problem is that I have a category of spells that I’m placing as an area directly beneath the player’s feet. Whenever anyone touches the spell’s area, I need to know. The problem is that I have no idea who’s in the collision area when the spell is spawned. If the player (or a creature) leaves the area and comes back in, I’ll receive a begin overlap event as normal, but I need to know without having to leave the collision area and come back in. Also, as one would expect, setting the collision to block instead of overlap gives a notification, but stops the player from moving at all, which is certainly not desirable (players and creatures should be able to run over it).

For reference, I am using UE 4.9 and I am looking for an answer in C++, as I do not use Blueprints. Thank you for your time.

I reckon you are using a primitive component to do the overlap notifications, in which case I believe these are what you are looking for:

	/** 
	* Returns the set of actors that this component is overlapping.
	* @param OverlappingActors		[out] Returned list of overlapping actors
	* @param ClassFilter			[optional] If set, only returns actors of this class or subclasses
	*/
	void GetOverlappingActors(TSet<AActor*>& OverlappingActors, TSubclassOf<AActor> ClassFilter=nullptr) const;

	/** Returns list of components this component is overlapping. */
	UFUNCTION(BlueprintCallable, Category="Collision", meta=(UnsafeDuringActorConstruction="true"))
	void GetOverlappingComponents(TArray<UPrimitiveComponent*>& InOverlappingComponents) const;

The actor.h class also has an overlapping components function, but I am not sure whether it works the same as the primitive component class functions.

	/** Returns list of components this actor is overlapping. */
	UFUNCTION(BlueprintCallable, Category="Collision", meta=(UnsafeDuringActorConstruction="true"))
	void GetOverlappingComponents(TArray<UPrimitiveComponent*>& OverlappingComponents) const;