Why is the instance variable ignored?

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I have a screen with multiple buttons on it. Every button is supposed to show a certain fact. I want to specify by an instance variable which fact every button is supposed to show when I click it.

    But what is weird is that whenever I click a button, only the instance variable of the first button on the screen is used, although I assumed it should pick the variable of the button I just clicked.

    Here is the code:

    This is how the button looks in the editor:

    I am confused, because I assumed my intended behaviour is what the instance variables are made for. But for whatever reason, they are all ignored, and just the instance variable value of the first button (and the one with the lowest UID) is picked. Can I do something to fix this?

  • The picking looks fine but we can't see everything. Check the instance variables on the objects are correct. Does the global variable update as expected? Do you have more than one text object?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes, every button has their own instance variable. When I change the instance variable of the first button, e.g. to 3, that becomes the "standard" which is picked everytime.

    The global variable does not update as expected and the text isn't updated correctly as well. Everytime only the instance variable of the first button is picked (and set / displayed).

    How could I show it better to you?

  • Holy moly, I found the problem! I had used the command "Set Fact Number to FactShareButton.FactToShare" in a function previously. I already assumed that that was the cause of the problem and had moved the command to the "touched" event. But I did forget to delete the old line which was then overwriting my command... Thanks for sticking with me!

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