[SOLVED]Comparing variables of different family members...?

Get help using Construct 2

Post » Mon Jan 25, 2016 3:19 pm

Hello World,

Please check the capx below. As you can see I have 2 families, one with monsters and one with ammo. And each member of each family has different properties defined in instance variables for each object ammo/monster type(the shape it is, circle, square, etc.), what color it has, and if it has any signs on it.
Then you will see I have one event AllAmmo on collision with AllMonsters.
I would like someone to please make the code there to show me how to do the following:
- when an ammo colides with a monster pick only the 2 members of each family that have just collided(as I understand C2 does this automatically because it's a triggered event and because of how families work?)
- then(on that collision) compare the instance variables of just those 2 members that have just colided to see if they are equal ammotype=monstertype, color=color, sign=sign(and remember these variables are on each object itself, not on the family)
- if all variables are equal call function x, else(if any of them is not equal) call function y

Capx link: https://www.dropbox.com/s/juvesdjguknqs ... .capx?dl=0

If you have any questions let me know. Thank you.
Last edited by VIKINGS on Mon Jan 25, 2016 6:41 pm, edited 2 times in total.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Mon Jan 25, 2016 4:01 pm

Put the instance variables on the Family, not the Sprites.
ImageImageImage
B
71
S
20
G
190
Posts: 3,533
Reputation: 108,340

Post » Mon Jan 25, 2016 4:10 pm

I can't do that @blackhornet I have hundreds of objects and for each of them those 3 variables differ. So first of all it would take forever to do and second of all I don't even see how that would help.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Mon Jan 25, 2016 4:17 pm

VIKINGS wrote:second of all I don't even see how that would help.


It would help with comparing the variables, which was your question, right?
If the family doesn't have variables, there is nothing to compare..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jan 25, 2016 4:24 pm

Give it a try. You misunderstand how Family instance variables work.
ImageImageImage
B
71
S
20
G
190
Posts: 3,533
Reputation: 108,340

Post » Mon Jan 25, 2016 4:35 pm

I misspoke there @LittleStain what I meant to say was "I don't even see how that would work."
Could you guys please use that capx, modify it to show me what you are talking about? Because I don't think we're on the same page...
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Mon Jan 25, 2016 4:48 pm

ImageImageImage
B
71
S
20
G
190
Posts: 3,533
Reputation: 108,340

Post » Mon Jan 25, 2016 5:16 pm

Ok, that's what I suspected you might be talking about, but I don't really understand how that works @blackhornet .
So when I do that it's gonna pick the value of the instance variable from the object that just colided then automatically copy that value into the instance variable of the family(if they have the same name?) and then compare variables of the families which now have those copied values to see if they match?
Is that what's going on, or am I getting it wrong, how exactly does that work?

LE: And then I'm gonna right click on those 3 conditions, add else, and that "else" is gonna mean "if eighter of those 3 is not equal then do this"?
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Mon Jan 25, 2016 5:32 pm

You are overthinking this. A Family is just a way to group objects. There is no separate storage, those instance variables are now part of each of those objects, that's why you can set them, even though you are clicking on the base object in the GUI (GreenSquareAmmo, for instance. Clicking on that object shows the instance variable are already there, the same as that object's own instance variables).

LE: yes, if any of those 3 are not a match, Else will run.
ImageImageImage
B
71
S
20
G
190
Posts: 3,533
Reputation: 108,340

Post » Mon Jan 25, 2016 6:36 pm

Well, that's me, I always overthink things. Ok, thanks for the help and explanations @blackhornet , time to get back to work I guess.
Sadly it seems that now I have to delete the variables for all the objects(and I have hundreds of them...) then add them to the family, then go and edit them again for each object.... It's gonna take forever, sigh...:(
B
21
S
11
G
6
Posts: 414
Reputation: 5,335


Return to How do I....?

Who is online

Users browsing this forum: jwilkins, Magistross, the_Shit_hawk, Yahoo [Bot] and 12 guests