How do I select different instances of the same object?

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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.

  • 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.

  • 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

  • "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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think I figured it out! I have to use "Pick all" before starting the 2nd loop.

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