Hi, I wanted to ask what the order of Execution of BeginPlay Events is.
My Goal: I have two Blueprints. The second one needs a reference to the component of the first one, and it needs it at the beginning of the game.
So my first blueprint creates a public variable holding the reference, during construction script (so it should be there right after I place the blueprint in the editor):
In my Level Blueprint, I set another public variable of the second blueprint to that reference (at BeginPlay):
Finally, in the second Blueprint, I use the variable to call a specific method of it:
Render Pointcloud Method I check whether the “PointcloudRenderer” is set - and it isn´t during first execution.
How can I build this up, so that
Render Pointcloud is called after all variables had surely been set?
You can have your second blueprint contain a reference to the first blueprint that you can set in editor. That way it can get the component itself on BeginPlay before it needs it.
Regarding he execution order, check my answer here, especially the link. The order is different for editor and stand-alone.
One way to handle the order of execution, is to use a single Begin Play (in GameMode, for example) and use it to spawn dynamic objects and have their Custom Events / Construct / Dispatcher scripts executed from this single entry point.
Hm yeah that could be an idea. Problem is, though, that I want just a reference to a (c++ written) component, which is part of the blueprint. So later I can maybe use different blueprints having that component, and not be bound to the blueprint itself
Thanks, this is a really good post! =D
Now I can see that the problem was that in editor mode the level BeginPlay is executed after the Actor BeginPlay (in this case my Blueprint).
Yep, using Custom Events did the job for me. I created two of them in my second blueprint:
And called them in my Level blueprint in the right order:
Thank you for your advice!