?RESOLVED? Create an object and pick it in the same tick?

0 favourites
  • 4 posts
From the Asset Store
Pick Up Items Sounds
$3 USD
50% off
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • UPDATE: I seem to have fixed it with smoke and mirrors. I added a binary numeral var which is not toggled until all of the characters are created. This toggle causes the variables to be set, but is positioned in such a way that they must be getting set on the tick following object creation.

    With the permission of the moderators, I'd like to leave this post in place for anyone else struggling with this issue. I wasted several days on it. I'm also hesitant to believe I actually understand what's going on.

    -----------------

    Hello all. I've been wrestling this for days, and scouring the forums and manuals, so I beg your pardon if this has been addressed elsewhere.

    I am trying to use Create Object to spawn several characters at once, then set instance variables for each of them within the same tick. I know that the first spawned object will be IID 0, because I destroy all objects at the start of the layout.

    The system seems to be either overwriting or completely ignoring those instance variables. I'm setting a text field to verify what's going on, and I get different results within the same tick depending on where that text is set.

    [attachment=0:3g1u9ajf][/attachment:3g1u9ajf]

    In the attached image file, everything works fine, and all the instance variables seem to be properly assigned. If, however, I move that Set Text event anywhere else in the program, including the blank sub event at the end of the attached image, the only instance that retains it's setting is whatever instance I pick first. I know it isn't just the Set Text that isn't working, because I'm tried retrieving the instance variables with subsequent mouse clicks, and those results match the Set Text's output.

    Is it just impossible to pick instances in the same tick as creation of the instance? That doesn't seem entirely true, given the positive results I mentioned. I have no idea what is going on here...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • As a quick followup, the order those functions in the image are executed is as written on pressing the Space bar. So, MakeNewPlayer -> MakeNewNPCs -> SetLocals.

  • I think you can only select the instance the tick it is created in the same subset of events, and nowhere else, Might be wrong though

  • My tests which resulted in the screen shot support what you're saying, I think. Per the update I just posted in the original message, I found that forcing the vars to not be set for at least one additional tick seems to have resolved the issue.

    Thanks for your quick feedback! Now that I've resolved this, I can actually start working on the Families related issue that I originally set out to investigate with all this. One problem solved, two more corp up. Yaaaay...

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