What are the benefits of 'families'?

New releases and general discussions.

Post » Mon Jan 26, 2009 11:45 pm

I'm struggling to properly understand the concept of families after reading the Wiki. Just to what extent can we use them to make, let's say, enemies? I'm now trying to get an Action RPG system up and running and I'm trying to create two enemies in the 'Enemy' family . I know that families allow me to assign each object the same private variables and allow me to create events for them as a whole, but from what I've tried, the type of events one can set is limited. Also, isn't there a way to make containers part of a family? For example, instead of adding HP Indicator to each object of the family, is it possible to add a container to all the objects at once?

It's very handy for setting health and strength since it creates those variables immediately, but in the end I can't create something like 'Enemy collides with Sword > Subtract 10 HP', since all the enemies in the family will lose 10 HP, unless I'm doing it wrong. From what I've tried I'll have to do it like this: 'Spr1 collides with Sword > Subtract 10 HP', 'Spr2 collides...', etc.

Also doing something like 'Always > Enemy: Add LOS obstacle 'Barrier' seems to crash the program, so I have to do it separately ('Spr1: add...' Spr2:add', etc.).

In the end, will I have to create a seperate event sheet for each enemy which has slightly different behaviour values (e.g - bullet speed, LOS Acc., Grid movement, etc.)?

I probably do have the wrong idea of what a 'family' is.
B
2
S
2
G
3
Posts: 143
Reputation: 1,536

Post » Tue Jan 27, 2009 12:00 am

[quote="Shady":18ri3ogn]I can't create something like 'Enemy collides with Sword > Subtract 10 HP', since all the enemies in the family will lose 10 HP, unless I'm doing it wrong.[/quote:18ri3ogn]
You must be doing it wrong. Families obey ordinary object picking rules. In that event, only the objects that meet the event will be affected.

[quote:18ri3ogn]Also doing something like 'Always > Enemy: Add LOS obstacle 'Barrier' seems to crash the program[/quote:18ri3ogn]
Crashes are always bugs, please submit them to the tracker so we can make Construct more stable!!

See the attached file. It's a quick example proving events involving families work only on the right instances. It's also got a quick and dirty health bar implementation. The health bars are not in a container with the objects, they just 'naturally' pair up one to an instance if there's the same number of objects of each. This works with ordinary types as well and can be very useful. Hopefully it will help you see the real use of families. They can save a LOT of repeated events. I don't know how I'd manage without them!
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Tue Jan 27, 2009 12:28 am

[quote="Ashley":1b379vbz]You must be doing it wrong. Families obey ordinary object picking rules. In that event, only the objects that meet the event will be affected.[/quote:1b379vbz]
Got it working! Well, sort of.

[quote="Ashley":1b379vbz]Crashes are always bugs, please submit them to the tracker so we can make Construct more stable!![/quote:1b379vbz]
Just submitted that one and another which was bugging me, though is the tracker working properly? Can't see any other listings like before.

[quote="Ashley":1b379vbz]See the attached file. It's a quick example proving events involving families work only on the right instances. It's also got a quick and dirty health bar implementation. The health bars are not in a container with the objects, they just 'naturally' pair up one to an instance if there's the same number of objects of each. This works with ordinary types as well and can be very useful. Hopefully it will help you see the real use of families. They can save a LOT of repeated events. I don't know how I'd manage without them![/quote:1b379vbz]
At first I tried making it custom, though then I discovered containers and thought I wasted my time since it does it for you! Ah well, the method I was trying to accomplish was much too complicated anyway. Yours is so simple and yet accomplishes the task perfectly. Mind if I use yours? :mrgreen:

Ah wait, but I'm spawning enemies... Is there a way to create the same numbers of bars as enemies? Wait, I could just spawn a bar along with an enemy!


Thanks for your help. Guess my understanding of families wasn't too far off.

EDIT: I tried replicating your destroy method, though I'm using boxes and texts which don't have a pick random action. Is it possible to add those in future builds?

Also, this may be a little off-topic, but is there a way to make an object move towards another while keeping the grid movement? So far I've been using rotate to player with a bullet, which complete ignores the grid movement and goes directly towards the player.
B
2
S
2
G
3
Posts: 143
Reputation: 1,536

Post » Tue Jan 27, 2009 1:08 am

[quote="Ashley":2whjljw7][quote="Shady":2whjljw7]I can't create something like 'Enemy collides with Sword > Subtract 10 HP', since all the enemies in the family will lose 10 HP, unless I'm doing it wrong.[/quote:2whjljw7]
You must be doing it wrong. Families obey ordinary object picking rules. In that event, only the objects that meet the event will be affected.[/quote:2whjljw7]
sometimes it is a little finnicky. for example, if you test for a collision but list the family item second, it might pick all the items within that family. so if i'm testing collision between two families, in the past i've had to check collisions both ways for proper picking

A overlaps object B
B overlaps object A
> do action

i haven't tested this extensively -- just a bandaid solution to a problem i've run into once.
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Tue Jan 27, 2009 10:31 am

It shouldn't really matter which way round it is... could you send me an example of the order being important?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Tue Jan 27, 2009 3:56 pm

[quote="Ashley":27c5n33q]It shouldn't really matter which way round it is... could you send me an example of the order being important?[/quote:27c5n33q]

Unfortunetly it does. Even yesterday when i was making an event for character movement, and when i setted up the condition :"<reverse> 'move left' pushed down, 'move right' pushed down -> play animation 'walk' " it did not worked at all. i had to set it up where 'move right' was first.
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
71
S
19
G
19
Posts: 1,919
Reputation: 16,910

Post » Thu Jan 29, 2009 10:12 pm

Wow! What an timesaver:) I should really read the tuts and wiki :oops:
B
33
S
15
G
6
Posts: 242
Reputation: 4,343


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 4 guests