0 Favourites

Sub-families and variables shared between families.

  • So, I have 2 families of objects, and some objects that belong to both. I have a family variable that needs to be accessed when calling this object as a member of either family, but I can't find a way to do this- you can't have the same variable in both families. I'd like to make one family a sub-family of the other, or make both sub-families of another group, but there doesn't seem to be a way to do this. What can I do?

  • You need to rename either 1 or both of the variables with same name. This rule applies to behavior names as well. I don't think the sub-family concept is possible.

  • You need to rename either 1 or both of the variables with same name. This rule applies to behavior names as well. I don't think the sub-family concept is possible.

    The problem is that I want the same variable to be accessible from both families, so changing the name won't help. I don't think it's possible with Construct 2 either, to be honest, but without it I'll have to make a lot of changes so I'm getting desperate

  • Either remove 1 object from 1 family and use the family variable which has maintained that object

    OR

    just use another family with both same objects and add a new family variable for this new family.

    continuously transfer the value of the old variable to new variable

    Then use this new variable for whatever you need

  • If you mean differentiating between two families you can do that by picking the UID of the object that is equal to the UID of the other family.

    E.g.

    Pick familyA.UID = familyB.UID - - > [action]

    Not sure that's what you're trying to do though.

    Having the same variable for both families could be achieved by having another family dedicated to all the variables shared by the objects, but that's not the best and certainly not the most efficient way of doing that I suppose.

    Transferring the variable to the other family could get really messy by the way.

    Edit: Also, the above method would mean needing to do this differentiation condition every time you wanted to change the variable in an event for only one family.

  • If you mean differentiating between two families you can do that by picking the UID of the object that is equal to the UID of the other family.

    E.g.

    Pick familyA.UID = familyB.UID - - > [action]

    Not sure that's what you're trying to do though.

    Having the same variable for both families could be achieved by having another family dedicated to all the variables shared by the objects, but that's not the best and certainly not the most efficient way of doing that I suppose.

    Transferring the variable to the other family could get really messy by the way.

    Edit: Also, the above method would mean needing to do this differentiation condition every time you wanted to change the variable in an event for only one family.

    Having a 3rd family that all members of both families are a member of certainly seems like the best option so far... but it's very frustrating, because all members of group A are members of group B but not vice versa, so sub-families would make everything very clean and logical and quick to do... your idea is the best thing available, though, I think.

    EDIT: actually, the 3rd group option wouldn't work because then I wouldn't be able to reference it in events using group A OR B!

  • I was more considering that like I have done in my project, you make the third family contain all the relevant behaviors. You would still need to differentiate between them though, but it's the cleanest way I have found so far.

    Also, you could use A or B to then select the same object in the third family, using a similar method:

    pick family3.UID = familyA.UID - - > action

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • It's possible

    Example:

    Family A:

    obj a

    obj b

    obj c

    instance variable Z

    Family B:

    obj d

    obj e

    obj f

    instance variable Z

    NEW FAMILY C

    obj a

    obj b

    obj c

    obj d

    obj e

    obj f

    NEW instance variable Y

    +whatever condition here

    Set Y to Family A's z variable

    +whatever condition here

    Set Y to Family B's z variable

    You have to use 2 events. Add the "For Each" accordingly

  • It's possible

    Example:

    Family A:

    obj a

    obj b

    obj c

    instance variable Z

    Family B:

    obj d

    obj e

    obj f

    instance variable Z

    NEW FAMILY C

    obj a

    obj b

    obj c

    obj d

    obj e

    obj f

    NEW instance variable Y

    +whatever condition here

    Set Y to Family A's z variable

    +whatever condition here

    Set Y to Family B's z variable

    You have to use 2 events. Add the "For Each" accordingly

    But the only way to do it like this would be to have a "for each" for every individual object setting Y to Z...

  • exactly, you intend to make the value the same for all?

  • Just be careful with the order of the Families, for my experience, its better to first choose the family that group more members that the other families, here's a closed bug about it: viewtopic.php?f=152&t=103761&p=778027#p778027

    I created a suggestion for getting some condition like Is Family Member: viewtopic.php?f=146&t=91500, maybe if we get enough people wanting this, we can have this on the next iteration!

    Also this tutorial can help: https://www.scirra.com/tutorials/556/un ... o-families

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