A major flaw with families...? [solved]

0 favourites
  • 3 posts
  • A while back I started putting all behaviors I want my objects to use in a "Behaviors" family. This way, I only have to code interaction with things like treadmills, springs, water, surface modifiers, etc. a single time, I'll only have one set of variables to mess with, and I'll have significantly more control over their behaviors as a whole. Frankly I think it's stupid to not do this or else you'll have tons of duplicated events with different objects.

    So let's say I want to add some enemies. I can make a new "Enemies" family and put my enemy objects in both the "Behaviors" and "Enemies" family. Now they interact with all the level objects my player does, and my player can interact with them as it should. Again, with only 1 set of events.

    But now...Let's say I want to disable an enemy's behavior, or change its behaviors' properties when it's damaged / had a spell cast on it. This is impossible because the two families the enemy is part of cannot 'communicate' with each other! I can't do something like:


    ENEMIES.hurt = 1


    ENEMIES platform behavior

    (because the platform behavior belongs to the "Behaviors" family, not the "Enemies" family...but the object is in both, so...what the hell?)

    So...what I've resorted to doing is making a "Units" family instead of a "Behaviors" family...and giving it extra variables to decide if an object in the family is an enemy, boss, etc. Problem with that is there's a TON of baggage - many objects in the "Units" family inherit dozens of variables and behaviors when they only need a few of them. For example, I want to put collectibles in my "Units" family so they interact with level objects and such - but now they have all the variables and properties that enemies do. I also get lots of conflicts (i.e. an object with Boss=1 also needs to have Enemies=1 so it interacts with the player properly. However, bosses and enemies work differently in some cases and can only be one or the other.)

    So I dunno. Anyone have a better way of handling this or do we just have to wait until C3 and (hopefully) proper inheritance?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can pick the 'other' Family object by UID, then you can address both as appropriate. It is an extra step, but may be easier than your Units mechanism.

  • That uh...never occurred to me...I use functions with UID params all the time, too. Bah! Still a workaround but ultimately cleaner than my Units method. I'll give it a shot!

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