Static Family instance variables?

0 favourites
  • 4 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hi all. Can someone please help me in figuring this out?

    Okay, so I have an enemy family, the family has a family instance variable of "HP" and I've set it to 100.

    I have a bunch of enemies in one layout and when damaged the HP value changes individually for each one, perfect so far.

    If I leave the layout however, and then come back to it later their health values reset to 100. I don't want that, I want the damage each of them took to persist between layouts...but family instance variables aren't static, and it doesn't seem that they can be set to be static either. I mean, I think I understand why they can't be static but I'm not sure what else to try now.

    Global variables don't make a whole lot of sense for multiple enemies of the same type, right? And local variables have always confused me a bit to be honest and I'm not sure how to implement something like that anyway.

    Any solution to this problem? Thanks for any help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi

    Put the Persist behavior on your enemy family.

  • Haha can't believe it was that simple.

    Thanks a lot!

  • You are welcome^^

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