Doubt about UID and instances.

0 favourites
  • 4 posts
From the Asset Store
Act on your instances, get/set their properties and variables only thanks to their UID. No more picking trouble! Plugin
  • Hi!

    I am trying to make this buttons change the values of some gobal variables.

    By now, all the buttons are the same object, and I'm calling each instance of them by looking at each's instance UID.

    So, the code looks like:

    <img src="" border="0">


    And the project's layout is:

    <img src="" border="0">


    Unfortunately, the idea doesn't works and even clicking on the buttons and the variables don't change. Perhaps the code isn't correct.

    Here is the project file:


    I presume that picking an instance n? is the same as select its UID.

    Any advice on why buttons don't change the variables as they're supposed to do?

  • UID and IID are different from each other. You pick by IID.

    UID is unique.

    IID only is unique along all instances of an object and gets automatically assigned starting at 0 and counting up.

    So your code would need to be

    pick instance 0 of button

    pick instance 0 of text

    pick instance 1 of button

    pick instance 1 of text

    Or you swap it with picking by UID, then your code would work as well.

    I probably would give each object an instance variable though and identify them with the help of this variable. So for example the buttons get a variable named buttonID, you set it to a different value for each button and can pick them with by comparing the instance variable.

    This will be a more descriptive way of doing things and could help you to understand what exactly the code is doing, when you come back to it later on for whatever reason.

  • mindfaQ, thanks a lot for your answer. It has given me the key to solve the problem. Two thumbs up!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Tanks! It works

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