Load order troubles. And solution.

I am not sure if this was proposed, I do not know keywords to use for search.

My problem:

  • load order of actors is kind of random from my POV. All i know is that game mode will usually load first.
  • to get any communication between blueprints i need to have reference of other blueprint
  • this is impossible if that other blueprint was not loaded to level yet
  • yes there is hax solution to add some delay to begin play, but it is hax and not proper programming, so i refuse to use this.

I call those HEISENBERG BUGS, because until i run project i do not know if i have them or not.

My solution:
Add some property that forces actor to be loaded in first batch. So everything else can be sure that actors from first batch are already loaded.

Ps.
I am not sure this could be already solved, I honestly cannot think of keywords to use for search,

Do you mean that the actors in your level load in different orders?

Or are you specifically talking about game mode / game instance / etc?

If you’re talking about actors, then you should rely on load order.

If you’re talking about background tasks, then

My problem is that i have actors in level, each has 3d widget component.
They all should hook to dispatcher or just cast to to another actor and read information.
Yes delay of (0.2) solves most, but imo it is a hack.
Reading (And looking for base actor) in event begin play sometimes works sometimes does not (depending on load order), on top of all that those 3d widgets initialize their umg widgetes wits some delay.

Yes i can make code that tries to cast to “source of data” and if it fails wait for next 0.2 seconds.

But it is not what “begin play” should assure? Or event “level loaded and ready” ?

And on top of it all I am not sure that this will work on different platforms, or even as standalone game. I have seen similar errors when i tried to do android build.

So all I am asking for is some predictability.

Delay is defintely out.

All the actors in the level will be able to talk to each other on begin play.

They can all also talk directly to their widget component.

What’s the dispatcher for?

i have actors that have 3D widget component. Those components are loaded with some delay (probably after player UMG is loaded and activated in player pawn).

Can you wait for them to be valid?

Yes, but that is delay. I can solve this problem, but every solution is kind of dirty trick.
And best solution would be to have either delayed load or load first property for actors.

I’m not sure if this will work for you, and it’s probably right in there as far as hacks go, but something I’ve done in the past to overcome that is to do that kind of setup in the first “tick” of the actor…

Most stuff like this can be overcome with using game mode as middle man. But it does not feel right, when widgets in 3d space communicate with player pawn trough game mode.

Also in past i had different load orders in PIE , standalone and then deployed on different platforms. So that 0.2 delay may be causing bugs on mobiles, when stuff takes longer than 0.2 seconds to load. This is why i consider it dirty hack.

Not just a delay, but a short delay on a loop, waiting for the actor to appear :slight_smile: