Problem with selecting object by UID

Discussion and feedback on Construct 2

Post » Fri Jul 01, 2016 1:30 pm

Hi!

I have a problem selecting object by UID. I am creating objects in pairs, on creation I put UID of one object into Instance variable of other. Then when I want to move one object toward paired one, it should pick coordinates from picked object and go there, but all objects are going towards the same target.

Object creation
Image

Object and value assigning works fine, fish has proper UID in Instance variable

Then I try to use that value like this:
Image

in first condition instance of Fish is picked, in second, paired instance of Target from UID should be picked, but it always picks first instance of the Target.

Any idea what I am doing wrong?
B
58
S
9
Posts: 22
Reputation: 3,953

Post » Fri Jul 01, 2016 1:43 pm

Try a For each Fish before the Target pick.
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198

Post » Fri Jul 01, 2016 1:53 pm

Thanks it works, but shouldn't it work without it, because fish is already picked in first condition?
After all, in Angle(Fish.X and Fish.Y...) it works with that instance.
Now I have an extra loop, not very efficient.
B
58
S
9
Posts: 22
Reputation: 3,953

Post » Fri Jul 01, 2016 2:01 pm

C2 does the looping for you if you only reference a single object. As soon as you need to deal with two different objects, you have to force the loop yourself, or you don't get what you want. In every other language, you would do a Foreach Fish every time.
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198


Return to Construct 2 General

Who is online

Users browsing this forum: Google [Bot] and 2 guests