[Resolved] Family instance variable keeps showing as 'varies'

0 favourites
  • 3 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • See edit below, but this was my original problem...

    I have a family of enemy objects called 'enemies'. Enemy objects are sprites, and I have 2 different enemy types in the enemies family, a zombie and a werewolf. The enemies family has an instance variable called health, and I want to set the default value to 2.

    If I edit the family instance variables, the health IV shows 'varies', even though I have no instances of the enemies objects in any of my layouts. If I try to set it to 2, when I hit enter it goes back to showing 'varies'. If I add a zombie or a Werewolf to my layout, they have a health of 1. If I change their health to 2 and then add another of the same enemy type, the new enemy has a health of 2. But if I delete all instances of that enemy type and then add a new one, its health is set to 1.

    Edit:

    OK, so now I'm REALLY tripping out! I just saved my project, reloaded C3 in my browser, and reloaded my project, and now all family instance variables are set to 0 / blank strings and I can't change their default values!!! If I create a new i.v. I can set it's value properly, but I can't set values for any of the existing i.v.'s. Man I hope someone knows how to fix this and I don't have a corrupted project.

  • So maybe I'm just not understanding how initial value of instance variables work!?!

    I cracked open the archived layout.json files and pulled the i.v. values I had been using, so I'm good there (I had lots of specific cryptic values I wouldn't be able to remember).

    More importantly, I was assuming that the "initial value" operated like a "default value", meaning that value would be inherited by the corresponding i.v. of any object in the family when created. Instead it seems like C3 has a different, rather confusing way of inheriting values, and the initial values are specific to the object instance. This post goes into detail:

    construct.net/en/forum/construct-3/how-do-i-8/instance-variable-initial-139702

    Looks like others have been confused by this concept before, I haven't seen it called out in the documentation so an explanation in the docs "instance variable" section would probably be helpful to other newbies like me.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Instance variable values belong to instances. If there are no instances in the project, there are no instance variable values to display. So Construct can't show you a value or let you edit it. You should add at least one instance somewhere in your project, if necessary on an unused layout. And then an instance exists, which has instance variable values, which you can then edit.

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