Detect collisions on BeginPlay

In the game I’m working on it’s possible for an actor to spawn on top of the player and I’m looking for a way to detect that and move the player out of the way. I know you can tell the SpawnActor function to adjust the spawn position if there’s a collision but the nature of the game means we don’t want to adjust the position of the newly spawned actor but rather move the player out of the way.

I was hoping either an overlap or on hit event might happen when the new actor is spawned and I could detect things that way. Unfortunately overlaps don’t seem to happen when the 2 components would block each other and hits don’t happen if you aren’t moving. So my player just gets stuck in the middle of the new actor and can’t move.

What would be the best way of detecting an actor has spawned on top of another actor? Thanks.

kgamble, I too have been frustrated that overlap events don’t get triggered automatically if two actors start out overlapping. But you can use the “Is Overlapping Actor” blueprint node to explicitly check whether two things are overlapping. So right after spawning your actor, use this node to test whether it overlaps with your character and if it does, move your character somewhere else (the logic for this is up to you to implement).

Unfortunately IsOverlappingActor just checks the list of overlapping components and since I’m looking for blocks rather than overlaps that doesn’t work for me. Thanks for the suggestion though.

I decided to just go through all the functions available to me on my actor and its root component to see if anything looked like what I needed. UPrimitiveComponents have the “ComponentOverlapMulti” function which does exactly what I want. I called that on my root component, passing in the position and rotation of my actor and that gave me a list of anything it overlapped with and whether the overlap was blocking or not. Then I just filtered looking for any of my characters that might be colliding with the new actor. If you only need to look for one specific actor you can also just use ComponentOverlapComponent and pass in the RootComponent of the actor your checking along with its position and rotation.