Clarification on Family feature

0 favourites
  • 10 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • I have been reading the manual and seen the posts online but it is still not clear to me, perhaps someone can shed some light on this one.

    I am trying to give a health value to each character within the same family, but of course if the instance belongs to the family, then all children shares the family health value, instead I want each child to have its own value.

    If I give the health value to the child, then I cannot use the family anymore within the events, and I need to make an event for each type of enemy, therefore the commodity of having everything within a single family event becomes pointless.

  • No, that's not true. Giving a Family an instance variable is no different than giving the object an instance variable. Each item in the family gets a unique value, as long as you've picked just the one family item. Chances are you have a bad condition. Post a case of it not working, and someone can help sort it out.

  • I am not sure how can it be a bad condition, it makes sense to me.

    If the family variable of Health is 5, then all of its children will have 5, why should there be different values for each?

  • You just said you wanted the values to be independent, and that it wasn't working. So what doesn't work in the code you posted?

  • Of course I have not implemented this into code because as I said I Am not sure how to assign different health values to each destructible, but wanting to have it controlled by a single event, without having to go:

    subtractfrom: Health item_1

    subtractfrom: Health item_2

    subtractfrom: Health Item_3

    What I want is

    subtractfrom: Health family

    Then each item has a value associated with health so it knows which one to call.

  • Here's an example. Three different sprites in a family. Clicking each changes just the individual family instance health value.

    blackhornettechnologies.com/Construct2Stuff/BlackRabbit_FamilyExample.capx

  • Thanks, I get that far.

    But how do you set sprite1 to have 1 health point, where as sprite 3 has 3 health points?

    Currently they all have the same health.

    My question is, and it is clear that I have not asked it correctly enough, is how do I assign different health value to each item, without having to go and add an event for each item type?

    So I do not want to have to check if it is colliding with 1, then subtract from sprite 1, if it is colliding with 2, subtract from 2.

    I want to make something less clunky and more streamlined.

    (just so we know, this was explained here, but I do not understand at all how to implement this solution construct.net/en/forum/construct-2/how-do-i-18/families-objects039-private-51315).

  • Put the hit value on the other object, and subtract it. You should be able use a family again, assuming they are different, and assign it at either edit time, or runtime, as created.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • As said in my previous post, this solution was already presented but I have trouble understanding any of it.

  • Ok problem solved, and I do not understand why this is not clearly explained anywhere, because it is really that simple, so I am going to do it below in case in the future someone is going to look this one up.

    Assign a numerical "health" Instance to the family.

    click on any family member and on the PROPERTIES panel, you will now find the newly created variable "health".

    You can modify this variable for each family member by clicking on them and going into the properties.

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