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

Discussion and feedback on Construct 2

Post » Sat May 23, 2015 6:13 pm

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:

+If ENEMIES.hurt = 1
-Disable 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?
Last edited by Tokinsom on Sat May 23, 2015 8:19 pm, edited 1 time in total.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Sat May 23, 2015 6:48 pm

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.
ImageImageImage
B
71
S
22
G
257
Posts: 3,790
Reputation: 142,696

Post » Sat May 23, 2015 8:12 pm

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!
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 7 guests