Sub-families and variables shared between families.

Get help using Construct 2

Post » Tue Apr 29, 2014 10:52 am

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?
B
11
S
1
Posts: 26
Reputation: 1,104

Post » Tue Apr 29, 2014 10:57 am

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.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Tue Apr 29, 2014 11:00 am

sgn15 wrote: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 :P
B
11
S
1
Posts: 26
Reputation: 1,104

Post » Tue Apr 29, 2014 11:08 am

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
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Tue Apr 29, 2014 11:09 am

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.
B
42
S
14
G
3
Posts: 165
Reputation: 5,115

Post » Tue Apr 29, 2014 11:15 am

Sumyjkl wrote: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! :(
B
11
S
1
Posts: 26
Reputation: 1,104

Post » Tue Apr 29, 2014 11:22 am

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
Last edited by Sumyjkl on Tue Apr 29, 2014 11:24 am, edited 1 time in total.
B
42
S
14
G
3
Posts: 165
Reputation: 5,115

Post » Tue Apr 29, 2014 11:23 am

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
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Tue Apr 29, 2014 11:31 am

sgn15 wrote: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...
B
11
S
1
Posts: 26
Reputation: 1,104

Post » Tue Apr 29, 2014 11:33 am

exactly, you intend to make the value the same for all?
B
16
S
7
Posts: 301
Reputation: 2,726

Next

Return to How do I....?

Who is online

Users browsing this forum: ramyaswetha, Yahoo [Bot] and 4 guests