picking objects within a loop

Get help using Construct 2

Post » Fri Sep 05, 2014 12:18 pm

If I have a foreach (family)

I want to pick the closest other member of that same family and put it's values in the current foreach family member...

How do I pick the closest (or based on whatever) family member and distinguish it within that loop from the current iteration family member when they're both the same family? Within the loop only one is picked... if I say "pick all" will it break that loop?

What's the best way for family members to pick each other?
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
70
S
19
G
5
Posts: 186
Reputation: 8,774

Post » Fri Sep 05, 2014 1:32 pm

for each family
set family variable var1 to 1
call function "check" param1 =self.x, param2= self.y
set variable var1 to 0(dunno if this will work)

on function "check"
family variable var1 does NOT equal 1
family pick closest to param1, param2
B
179
S
50
G
208
Posts: 8,721
Reputation: 128,810

Post » Fri Sep 05, 2014 2:13 pm

Oh I see basically run through twice... and have a flag to see if it's the one from the loop. Problem is you're still in the loop so within that loop only 1 family member can really be picked at a time... but a function frees that up and creates a new set?

If I have an event that says pick only THIS ONE member of a family...
then within that a sub-event that calls a function that picks from the same family... the picking starts over again within the function's events...hmmm.
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
70
S
19
G
5
Posts: 186
Reputation: 8,774


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests