What is ready 'on start of layout'?

Discussion and feedback on Construct 2

Post » Sun Jun 15, 2014 3:40 pm

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!
B
4
S
1
Posts: 4
Reputation: 258

Post » Sun Jun 15, 2014 5:53 pm

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.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,273

Post » Sun Jun 15, 2014 5:56 pm

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.
B
4
S
1
Posts: 4
Reputation: 258

Post » Sun Jun 15, 2014 9:10 pm

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
B
7
S
3
G
1
Posts: 184
Reputation: 1,352

Post » Mon Jun 16, 2014 12:01 am

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).
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Wed Jun 18, 2014 2:13 am

Thanks for the response Arima. Probably easier to delay rather than keep track of what I can do on the start of layout anyways!
B
4
S
1
Posts: 4
Reputation: 258

Post » Wed Jun 18, 2014 10:38 am

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.
Scirra Founder
B
387
S
230
G
87
Posts: 24,249
Reputation: 192,240


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests