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

Get help using Construct 2

Post » Wed Mar 26, 2014 8:34 pm

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.

CreatePick1.JPG


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...
You do not have the required permissions to view the files attached to this post.
Last edited by Angus OnAir on Wed Mar 26, 2014 8:51 pm, edited 1 time in total.
B
4
Posts: 8
Reputation: 241

Post » Wed Mar 26, 2014 8:37 pm

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.
B
4
Posts: 8
Reputation: 241

Post » Wed Mar 26, 2014 8:44 pm

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
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Wed Mar 26, 2014 8:53 pm

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...
B
4
Posts: 8
Reputation: 241


Return to How do I....?

Who is online

Users browsing this forum: David181, OBLIVION and 60 guests