Hi, so I have a few actors in the level and only one of them is firing the BeginPlay event. If I put more actors in the level and add the event to test, it does then work. So basically, sometimes it works, sometimes it doesn’t. Anyone encountered this?
Thanks.
Hey @AllGamesSuck!
So what I’m thinking here is possibly a load order issue.
What is on these BeginPlay events? BeginPlay runs when an actor is created, not when the game starts, so they run independently… But if there are references to things that don’t exist yet when they load in, that poses a problem.
Come back with some visuals!
You should put a breakpoint on the BeginPlay node (F9 key), run the game and see if the breakpoints all stop the game at the BeginPlay nodes. If so, there is no problem with BeginPlay.
It sounds really odd. However, I think I remember something vague like that happening if you forget to call Super (the parent’s “BeginPlay” node). Though that might have been a different case.
Thanks guys. So, there’s nothing attached to the BeginPlay’s. I use them just to test, with breakpoints on them. I did that because I wanted to check the load order on these actors, because I need to check collision between them on game start. The collision events weren’t triggering.
But anyway, I thought it’s maybe because I’m using children of the blueprints where I have the code. But then I placed a new actor with the BeginPlay straight in it, but still nothing.
Edit: I should say these actors are in a streaming level, which is inside a Persistent level. If I add a BeginPlay in one of the actors from the Persistent level, then all my other BeginPlays from the streaming level start firing as well, but I don’t need it there.
BeginPlay order is not reliable. When / if they execute depends on a few factors.
In the end, which is the issue that needs to be solved? that BeginPlay trigger, or the collision event not working?
Well, the collision event was nr. 1. I asked about that here:
No solution yet.
But I was thinking I could notify the loaded actor, when the other actor loads, through event BeginPlay, somehow. But now I don’t even have my events BeginPlay firing.
So this post should be about BeginPlay, I think. I just mentioned the collision issue in case it might be relevant.
I have a feeling this is because the level streaming, but I can’t answer that.
How to manage load streaming in relation to Actors with BeginPlay?
Level streaming: FlushLevelStreaming() causes BeginPlay() not to be called
Just a little update on this: since 5.5.4, I’m getting bits of streaming levels randomly poping up in the editor viewport, even though the levels are hidden. Also some actors (like Player Start) are sometimes not found by GetActorOfClass. Other actors don’t run their code anymore if you place new actors in the level. All sorts of weird stuff going on. Don’t know if the last update is the culprit, but I wish I could scream this out to devs, because they seem to have left the gaming part of the engine back in 2010. You have to put band aid on band aid to create basic gaming functionality.
Excuse my rant, but it’s frustrating. I’m stuck, and I don’t even know where to start looking for issues, let alone how to fix them.
Okay so a few things. This ^^ Happens when you try to get a reference to something before it’s fully loaded in. Running GetActorOfClass is gathering a collection of references- so it’s because they’re not loaded in yet. Put a delay there to wait a moment before gathering the refs and it should guarantee it. I think a lot of your issues may be based around loading in- if you’re attempting to reference something before it’s loaded in the BeginPlay, it’ll just fail because the thing you’re referencing doesn’t exist yet.