So I have this actor component with Event BeginPlay on my player character and other actors.
It seems to be running fine on the player character but not on the other actors.
The player resides in the Persistent level, while the other actors using the component are in streaming levels, if that matters.
Any ideas? Thanks.
Hi @AllGamesSuck,
Could you provide a little more context please? What component is breaking? What is your logic?
Is this custom (your code) actor component, is it in C++ or bps?
Because unreal has quite messed up order of events (that are all kind of begin play)
From what i remember:
- first all components initialize (C++ ones)
- then C++ actor that owns them all (also initialize).
- then i think actors post initialize in C++
- then begin play in c++
- then begin play in BP
Well i am sure i messed some parts of that also .
so in your case code it may be that Begin play on component happens before begin play in actor or even when owning actor is not yet loaded, you try to read some reference to not existing (yet) actor or variable, cast to fails and you did not hande that with some print so whole bp code dies out.
This is all blueprints. The component has saving logic on it:
…but it doesn’t even fire Event BeginPlay.
So, when I first start the game, I load my streaming levels. The actors inside these streaming levels don’t run this actor component.
But if I unload and then reload those same streaming levels in game, the actor components then fire. They’re just not running when first running the game and loading the streaming levels for the first time. These actors are children of children of parents, it’s like a 3 blueprint hierarchy, if that matters.
Also, for some reason, If I add breakpoints on my streaming levels logic, it works. Stops working when I remove them.
The logic starts in the Persistent level blueprint:
And continues in game instance:
The levels load fine, but the actors in them just don’t run their actor component, like I said.
Edit: After more testing I realised all actors in one streaming level are not running their event BeginPlay.
Hmm yeah, this sounds to me like a load order issue, like @Nawrot mentioned. It could be that the parent blueprint or a reference is not loaded when this BeginPlay is called, which also explains why it works when you stream in the level later. Have you tried building this out yet? Normally during a build it should spit out an error message if the load order is messed up.
If this is a blueprints-only project, I would suggest just manually loading in this level in last, to guarantee all its references are already loaded. If you’re using Cpp, you should have more control over the precise load order.
Use some good old print to log, in each begin play get actor name (self) print it out, and some message.
I see you are using breakpoints, and with breakpoints there is a problem. You put those in editor (source code) copy of actor, it is very easy to have that breakpoint in copy of actor that is not used in level. So use prints, to see if they are really not used, and to see order of begin play.
Yes whole loading order stuff is quite messed up, in unreal. However do not blame Epic, its mess from oop side more than epic fault.
However it could be nice to have real begin play.
This may have some clues (chat GPT aka yellow rubber duck) take on this problem:
In Unreal Engine, if you’re streaming in a level and actors inside it don’t have BeginPlay()
triggered, it’s likely due to one of the following issues:
Checklist for BeginPlay
to fire:
- Level is loaded but not made visible
BeginPlay
only fires when the streaming level becomes both loaded and visible.- Fix: Make sure you’re using
SetShouldBeVisible(true)
orLoadStreamLevel
withbMakeVisibleAfterLoad = true
.
- Actors are not considered part of gameplay
- Only actors that are “Actors in Game” will trigger
BeginPlay
. Actors marked as Editor-only or not placed in the persistent world might not trigger gameplay events. - Fix: Ensure your actor is not marked as
IsEditorOnly()
or part of a construction script-only logic.
- Streaming level is not loaded in the correct World context
- If you’re loading a level in the editor context (e.g., with the wrong world pointer or from an editor utility), then gameplay events like
BeginPlay
won’t fire. - Fix: Make sure you’re loading levels during actual gameplay, not in the editor or via
EditorUtility
.
- The level was already loaded and made visible before the game started
- If a streaming level is already loaded and visible at the start of the game, actors in that level may have already triggered
BeginPlay
before your logic runs. - Fix: Check the load order and ensure you’re observing the behavior immediately after the streaming.
- The level is not marked as a streaming level (or not properly referenced)
- If a level is not actually loaded as a sublevel in the World Composition or World Partition setup, then streaming behavior may not behave as expected.
Common Blueprint fix:
If you’re doing this in Blueprint, double-check the level streaming node:
- Use Load Stream Level.
- Check
Make Visible After Load = true
. - Optionally, wait for the Level Loaded and Level Shown output pins before proceeding.
ps.
Double check what ajj produced, they tend to make up “facts”.