Bind Event doesn't happen quick enough on Begin Play.

Hey all, I’m making a Scene Component and within it I want to spawn a Trigger Sphere and use that to determine when the player has overlapped it. If I start outside of the sphere and move into it it’s fine, but if I start within the sphere it doesn’t register the overlap.

I imagine it’s a timing issue so how could I get around not triggering when I start inside it? TiA

Try this:

for starters, binding to on overlap should be unnecessary, as the sphere should have an event, on begin overlap, which you can access from class defaults. Secondly, you could try delaying the spawning of the sphere till the next tick so it is loaded after the player, ad overlap would probably work. If that doesnt work and you know you the player will always spawn in the sphere, you could add the trigger to beginplay as well.

Unfortunately this option isn’t available within the Scene Component. I’m not overly happy with the way I’m introducing a Trigger Sphere then eventually a Sphere Collision component. If you think there’s a better way (within an BP Scene Component) I’d be happy to change it. Thanks

It’s an actor’s property - note Class Defaults. And you are using actor overlap. Select the actor to see it - it affects all its components. If the above does not work, or is not good enough, you can always fire an additional overlap:

image

The component initialisation order is gimmicky, so to speak. That’s why that tickbox exists.

One stupid solution that works for me

1 Like

This option isn’t available under Class Defaults within an Actor or Scene Component.

You need to do it inside the actor you’re spawning, have a look at my screenshot again. I am assuming you already have a fully fledged actor, of course. If not, extend it - looks like you can:

I’m generating the Trigger Sphere solely using the Spawn Actor node. It isn’t a BP or any type of asset prior to it becoming one in this component.

I can confirm this works, though it is somewhat baffling/ridiculous. Thanks!

1 Like

That’s why you’d create new class inheriting from the native one:

image

This way you can script inside it, thus extending its functionality.


Regarding what @kiruru002 mentioned. You can achieve the same by manually firing an overlap after binding, as suggested above. Technically it should work fine with that single frame delay but I would not ship it like this. Might work, might not.

stupid solution

It’s not stupid if it works. Does it, though? After packaging and all?

I packaged it for Windows just in case.
It seems that waiting one frame can cause collisions even in package builds. (Shipping and Development)

1 Like

I think that if you know that some actor spawns and will be overlapping another and you also need that overlap event to fire, it may be best to just call the overlap event as part of the blueprints initialization rather than count on delays or game start up ordering.

THat way you know it is going to work 100% of the time.

If there is a situation where the overlap may not happen so you dont want to hardcode it, you can do a special case where you check for overlapping actors rather than rely on the overlap event.

I think this may already be mentioned, sorry if it was, i just skimmed other comments quickly

2 Likes

It needs to be a component so that I can drag it onto random Actors in the level and I can set variables within the Details panel of said Actor. When I make a standard BP it doesn’t allow me this functionality.

image

1 Like

That setting should be set on those actors then…

Thank you!

Why didn’t I think to trigger the Overlap Event manually on initialisation!

1 Like

I mentioned it twice already. :innocent:

1 Like

Damnit! How did I miss that. My apologies.

1 Like

just needed some back up singers, lol

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.