How do I select different instances of the same object?

Get help using Construct 2

Post » Wed Apr 12, 2017 5:39 pm

Color-coded screenshot of what I've tried in Construct2: drive.google.com/file/d/0BxrM_LAQGwWyYTdFRWZES09CMDA/view?usp=sharing

Hi, I would like to select different instances of the same object which are nearby to another one, and repeat this process for all objects of that type.

I am basically creating a fighting game where the player objects need to be able to punch each other. The player who punches has to have a way to deal damage to all other player instances in the range. The sqrt formula in the image is checking the distance from one object to another. The red color is the player that does the punch, and the green color is the player that gets punched. However, when I run this code, the actions highlighted in green are acted on the object highlighted in red rather than the object highlighted in green. I don't know how to fix this code and I would greatly appreciate assistance. Thanks.
B
6
S
1
Posts: 14
Reputation: 380

Post » Wed Apr 12, 2017 5:50 pm

You use the "pick instance" condition under 'Systems' plugin.

I don't have time to modify your capx right now but check this out:
https://www.dropbox.com/s/p04xd82wc1n3m ... .capx?dl=0

To give you an idea on selecting instances.
Image Image Image
B
31
S
11
G
27
Posts: 748
Reputation: 17,093

Post » Wed Apr 12, 2017 10:17 pm

I dont understand your code at all.
Plz read https://www.scirra.com/manual/75/how-events-work

You pick 1 player. All the sub conditions start picking from that first pick.
Hence, those that you wanna pick are not in the picklist to start with.
Use a function to (broaden the picklist) start picking from scratch.
Better is to use a family.

Here is with functions:
https://www.dropbox.com/s/4tmc0p3io8gea ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Apr 13, 2017 4:14 pm

"You pick 1 player. All the sub conditions start picking from that first pick."

That's the problem. I need to have all characters interacting with all other characters. So if I have 3 characters, I need player 1's events to check for player 2 and 3, and then I also need player 2 to check for player 1 and 3, and then I need player 3 to check for player 1 and 2. I wanted to do this with a loop within a loop, but I can't figure out how to access the 2nd loop. Right now, if there are 3 players and the outer loop is on player 1, the inner loop runs 3 times on player 1 and zero times on everyone else because accessing "Player" is just accessing the one selected in the outer loop.

Also, Dropbox is blocked where I am.
B
6
S
1
Posts: 14
Reputation: 380

Post » Thu Apr 13, 2017 4:29 pm

I think I figured it out! I have to use "Pick all" before starting the 2nd loop.
B
6
S
1
Posts: 14
Reputation: 380


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 32 guests