How do I test two same object types same variables

Get help using Construct 2

Post » Mon Dec 15, 2014 4:28 am

I have all NPCs in my game under the same family and they all have a faction variable so to speak and I need them to only injure each other during attack sequences if the faction variables are different. How do I go about this?
B
45
S
13
G
1
Posts: 236
Reputation: 4,010

Post » Mon Dec 15, 2014 4:33 am

Create another family with the same objects in it, compare between the two families.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Mon Dec 15, 2014 4:37 am

But then all my variables like their stats and such don't carry over to the additional family very practically unless I'm not aware of something.

EDIT: I guess what I could do for melee attacks is the same thing I did for the projectiles and make melee collision objects and put faction values in them and create them for melee hits.
B
45
S
13
G
1
Posts: 236
Reputation: 4,010

Post » Mon Dec 15, 2014 4:55 am

You're right, that was more or less a shot in the dark since I can't check it myself. In that case, you'll need to make liberal use of the "Pick nth instance" event from the system object, which will pick a specific instance of an object type from the list of picked objects of that type. To compare variables between objects of the same type when multiples are picked, you can access variables of a specific object by specifying an index in parenthesis after the object name, like:

Code: Select all
Sprite(0).MyVar = Sprite(1).MyVar, do some thing
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Mon Dec 15, 2014 4:47 pm

I tried that, I think the (#) part is literal IID values. So it finds instances #1 in the entire layout when you put 0, #2 when you put 1, etc. The melee collision box idea works fine and is better than testing my whole sprite because melee attacks are restrained to a specific region now.
B
45
S
13
G
1
Posts: 236
Reputation: 4,010


Return to How do I....?

Who is online

Users browsing this forum: MrSkailo and 17 guests