Problem with selecting object by UID

0 favourites
  • 4 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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

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

    Then I try to use that value like this:

    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?

  • Try a For each Fish before the Target pick.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

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