Get Overlapping Actors with Begin Play. Blueprints

Hello. I have tried to get an array of actors which have a special component on Begin Play. The problem: it works only with delay or Event Tick. if i just remove the delay it doesn’t work. Can i attach the fuction to Begin Play or this logic is impossible with playing begin play?


this probably indicates that whichever actor this code is on is running its begin play before the components you are searching for have been initialized.

LIke this:
ActorA → beginplay → searches for componentX → componentX does not exist yet
ComponentX → begin play
ActorA → eventTick searches for componentX → componentX exist!

So, instead of begin play, you may want for componentX to broadcast itself via an event dispatch or something like that. This way you can be certain that it does in fact exist and has been initialized.

So componentX’s beginplay can put out an event dispatch, and any actors that want to communicate with componentX can bind to that event dispatch.

There are many other ways to accomplish the goal but the basic idea is that you want to be sure the target with which you aim to communicate with is actually there and ready.

this may be handy:
Game Flow Overview | Unreal Engine Documentation

it stops at “spawn actors” but I think the take away from that is, the order in which actors and components are created isn’t something you should rely upon or try to guess by using delays. It’s better to code in certainty so that failure is impossible.

1 Like

Thanks.