0 Favourites

What is ready 'on start of layout'?

  • Hi folks,

    I just started setting up some debugging for my pathfinding using the same methods found in the default pathfinding project (using a nested for loop with the obstacle check condition). When I used this method in conjunction with the 'On start of layout' condition, it was giving me an odd result of the grid being an obstacle. Of course, it took me a while to figure out that this was due to the fact that I was triggering on start of layout. Moving this to any time after seemed to work wonders.

    So that brings me to my current question. What exactly is ready of the start of layout? My understanding was that all objects would be ready, so you could do things for setup under this condition. Is the pathfinding grid just an odd one out? Is there a list somewhere?

    Any info would be appreciated. Thanks!

  • When you add an event to "On Start of Layout", that event is going to triggered at the start of the layout.

    It means you want it to start as soon as the layout starts.

  • I understand that Dom.

    My question is related to if there is anything else that is done in the background by Construct (like setting up the obstacle grid for pathfinding using solids) that will not always be completed by the time 'On Start of Layout' is called. For example, if you check if any cell is marked as an obstacle during this time, it will always return true. I'm not sure if this is a bug or if it is just due to the nature of the engine.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • another part of the same question is when you have multiple "on start of layouts", is there any particular order in which they are done, are they done in parallel? startup conditions are never trivial and race conditions which is what kyuur is talking about are a real problem in any hardware or software system.

    R

  • If you have two on start of layout conditions, they run one after another. That can be helpful if you want to create objects and then manipulate them (as objects are not fully created until the next base level event).

    If you're having problems, you can always use a variable to delay the action momentarily instead (if var ticksSinceLayoutStarted = 2, do events that would have been in the start of layout event).

  • Thanks for the response Arima. Probably easier to delay rather than keep track of what I can do on the start of layout anyways!

  • I think the pathfinding behavior is the only exception, since to build its obstacle map it also needs to know about any objects created on start of layout. From the second tick it should work though.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)