To Families or not to Families?

0 favourites
  • 6 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hi,

    I'm bit thorn weather I should use mostly families or just do events per object. The problem I'm facing with setting up actions primarily trough Families is that I have to create a lot of additional variables to check conditions for different types of AI, and after a while whole trees of events stop being clear to me, and start to blur with each other. On the flip side, with families I can just do single For Each, so then I only pick object once trough the whole loop, theoretically saving on some of the time those kind of loops need to go tough. But then again, in some circumstances, like with enemies, I'm seeing a possibility of triggering event every x seconds, instead of checking on every loop.

    So the question is, how do you go about that? What is the most clean and efficient approach? If you have a Family of enemies for example in which some of the enemies are mele and some shoot projectiles, do you just control all of them trough the family only, or you only use family actions for certain things... any help will be appreciated.

  • You can have multiple families. You could have all enemies in the Enemies family, as well as Mele and Projectile families. So you can pick all enemies easily, and then picking by Mele, on the UID, which only works if the object is Mele, and at the same level underneath, try picking the Projectile by UID, which again only works if the object is in Projectile. So the events only run based on the secondary family.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can have multiple families. You could have all enemies in the Enemies family, as well as Mele and Projectile families. So you can pick all enemies easily, and then picking by Mele, on the UID, which only works if the object is Mele, and at the same level underneath, try picking the Projectile by UID, which again only works if the object is in Projectile. So the events only run based on the secondary family.

    I have states and enemy types right now working in similar fashion. But thanks for an answer.

    I just have an idea, to create boo named busy, and so when I'm picking objects on the screen before "for each" I'll narrow that with "isbusy" condition. Will do that for some of the actions outside For Each. Might help in performance.

  • Specific to your question:

    If you have several objects that all need the exact same operation run like in a loop, that would be perfect for a family. At the very least, it simplifies your code a lot.

    More generally, I've been experimenting with families lately, and here's where I'm at:

    I think families are great if you have several different objects with general similarities, with subtle differences.

    So like in the kind of game I've been working on: a few enemy types, but they all have 1) pathfinding, 2) line of sight, 3) health stat, they would all go in a family like famFoe1. I can control all those common factors with a smaller amount of events, which is great for all the inevitable tweaking. If these enemies have different attacks, I am okay with creating individual cases for that.

    Families are also good for mental health. As long as objects with common factors are together in a family, it is faster to remind yourself of what-does-what, just by opening the family folder rather than looking up each individual object.

    Another example:

    famFoe1: enemies with pathfind, LOS, health

    famFoe2: enemies that are weird and have only health in common

    famFoe3: includes enemies from families 1 and 2, so they drop loot when destroyed

  • I use a lot of families that keep behaviors and variables, but those stop me now from adding certain objects from different family, to a new family with which they'd share common actions.

  • My head exploded. I will just say 'always families'...

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