Families, targeting objects variable

0 favourites
  • 11 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • I cant seem to figure out how to target the variables of the objects in a family, it seems the only way to do so is to apply the variables to the family instead, in other words, if i wanted to have object 1 have a health of 10, and object 2 to have a health of 100,

    if i want to say if ( family

    ) health da da da, it is not impossible, is there anyway to do this?

    the family should target the objects variables in side of it FFS

    not apply variables to the familiy, what if i want the objects to have different stats? -.-

  • so its impossible then -.-   thats pretty lame

  • Do you have a CapX that shows your problem so we can help you work thorough it? You can change a single variable on an object if you program the events correctly... (Even using families...)

  • so you can change the variable of an object through a family event?

    so if hit family, check variable for object inside family?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Show us your capx file so we can help you break it down.

  • If you have to separate objects and give each a variable "health" then add both objects to a family then you can't access "family.health".

    Instead add both objects to a family and add a family variable "health" and then the objects will inherit "health" variables, then you can access "family.health".

    Does this help? If not a capx would help immensely.

  • so every object in the family would have a health of 0, if i wanted different things to have a different health i would have to on spawn tell them to change their health ?

  • You can set the default health to 0 but if you place a few objects in the layout you can change each object's variables to something different than each other. If you spawn an object via events, you just need to place an action in the same event block telling the object to set its health and it should only pick that freshly spawned object and not effect the others in the family.

  • I'm having the same problem as cs2curious.

    If we just go by the family example that comes with cs2, how would we give each of the 7 different enemies their own health value? If all code is being told is that the laser has collided with "a member of the 'Enemies' family", I want to say "-100 from it's health" but have the starting healths all different. I'm thinking it should be something like "-100 to [family].member.'health'"?

    So far I've just copied and pasted a heap of times but if I can find out how to do this it would save heaps of work.

  • A Simple way to use families:

    1. Add your sprites to the game (say all your "Enemy" sprites)

    2. Create a Family called "Enemy Family"

    3. Add all the enemy sprites to this Family

    <Key Part below>

    4. Add instance variables to your Family. Each variable will now become available to the individual members in the family

    5. In C2, you need to have at least one instance on the layout (maybe outside the view) to be able to create them on runtime. Make sure you have at least one instance of each of the Enemies created on the layout

    6. Edit the inherited instance variables of individual members in the Enemy Family. You will notice that each member retains the value set to its instance variable.

    Eg: 'Health' is a Family variable. 'Health' for EnemyMemberA can be 100 and for EnemyMemberB can be 200.

    Even when you spawn individual Family Members at runtime, they will get created with the initial set of individual values for the instance variable.

    Hope this helps.

  • I'm having the same problem as cs2curious.

    If we just go by the family example that comes with cs2, how would we give each of the 7 different enemies their own health value? If all code is being told is that the laser has collided with "a member of the 'Enemies' family", I want to say "-100 from it's health" but have the starting healths all different. I'm thinking it should be something like "-100 to [family].member.'health'"?

    So far I've just copied and pasted a heap of times but if I can find out how to do this it would save heaps of work.

    Blam,

    I haven't tried this, but I guess what would happen is that the correct value would get deducted from Health. You just need to have [Family].Health.

    In the Event, when the 'Laser' strikes the 'Family', the individual member instance would get filtered from the entire set of [Family].[Members].instances.

    Also, see the remark I added a while earlier on easy usage of Families.

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