Picking created objects

0 favourites
  • 12 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Quick question...

    Why does this work...

    <img src="http://www.mbcoffice.com/construct/works.png" border="0" />

    ...and this does not?

    <img src="http://www.mbcoffice.com/construct/nowork.png" border="0" />

    It seems like none of the volumebar objects get picked in the second instance.

    I have tried adding a Pick All condition, but it still didn't work.

    Also tried adding it as subevent of the creation loop, where it works for the "sound" type volumebars only. This is expected, as I understand construct picks only the last created object within an event.

    Anyways, the situation first image works fine for my purposes, but I'd like to see if I can get an understanding of why the second one doesn't work. (Ideally I like to keep all my layout start events together, so this is really bugging me!)

  • There are some odd instances with object creation. The rule of thumb is that the object itself is not "fully" created until after the current "tick" is over, so it's not available to be picked again until the event sheet starts again.

    What I don't get is why would the 1st one work either, unless start of layout is valid for more than run through the event sheet.

    I'm as stumped as you are.

  • Read this for the official explanation. It's not the next 'tick', it's the next 'top-level event'.

  • It's the thing I still find most aggravating about C2, but the link explains why it's necessary. You get used to it, basically you just find ways to create your objects in one event then manipulate them in a new top-level event. 'On created' usually solves it but other methods, such as your top example also do the trick.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Aha! Thanks for that. Maybe something can be added to the manual section for system-create object regarding this?

    I guess I can split the creation event into two sub branches and have a sub event for each one setting the state.

    Or I can have two sets of Layout Start events for my projects, one for creating instances and another for setting them en mass.

    Anyways that clears it up. Thanks again!

  • Thanks for that link! Clears a lot up.

  • so the first one should work without the start of layout as well. Just make the volumebar statement the top level in 3

  • But then it runs every tick, continually setting Status=2.

  • run one time?

  • Do you mean 'Trigger once while true'? You may as well leave it as 'On start of layout'. Seems clearer.

  • Followup - Here is how I ended up deciding to do it, I felt it was the clearest way and doesn't break the logical flow of the code like having another "on layout start" would.

    <img src="http://www.mbcoffice.com/construct/solution.png" border="0" />

    On created might work well for other purposes, but did not for me in this case because the "Volume" instance variable I was checking against has not been set yet upon creation.

    I might have two on layout start groups like I mentioned earlier, if the project had a greater amount of situations similar to this. First one to create all the objects, second one to modify them.

    I did notice another oddity though, the on created events ran even when I had them after the creation event on the sheet. Guess they retroactively apply to everything was created during the tick!

  • I understand why you think several 'on start of layout' events seems messy, but in the end I had several anyway, just to split up the amount of stuff I need to do at start-up.

    This situation with needing to set variables for objects on a new top-level event has caused me lots of headaches, but there's always a solution.

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