I’m using different Defold assets. Because of that I have run into some issues related to order of execution of used Game Objects in my collection.
The question is if I have 3 objects A, B and C. How can I make sure that:
function init() of A is first to be executed
then function init() of B is Second
and init() C is third
I read the manual “core concept”, I couldn’t find something explaining the order of execution or how the engine decide which GO is first within the same GameCollection…
Game objects in Defold are designed to work independently of each other. What is the specific use case where you need to guarantee a specific order of initialization?
I put the camera with the hero collection and my controller object was supposed to make the link between the camera object and the hero object (using follow() function).
So the problem was that the controller was executing rendercam.follow() function before the init() of rendercam object… it didn’t work of course
but now I’m using msg.post in my controller as suggested by Pkeod. It’s working… following the debug I can see the message execution is done after init()
If you have some kind of HUD in your game, you can defer initialization of your game objects until the overlay loads. This is what I do in my game to resolve these concerns. The UI has always a slight delay of loading so if you wait for it then Rendercam should always be ready to go by then.