To Families or not to Families?

Discuss game development design and post your game ideas

Post » Sat Aug 19, 2017 3:41 pm

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.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Sat Aug 19, 2017 3:50 pm

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.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Sat Aug 19, 2017 11:24 pm

blackhornet wrote: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.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Wed Aug 23, 2017 1:34 am

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
B
36
S
13
Posts: 12
Reputation: 2,405

Post » Wed Aug 23, 2017 1:55 am

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 professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Fri Aug 25, 2017 3:47 pm

My head exploded. I will just say 'always families'...
B
46
S
16
G
79
Posts: 2,170
Reputation: 46,857


Return to Game Development, Design & Ideas

Who is online

Users browsing this forum: No registered users and 2 guests