Help with multiple enemies

Just started using Construct 2? Post your questions here

Post » Sat Dec 20, 2014 8:13 pm

Hi. Please, help! Im very new in Construct 2. Im learning while I make a plataform & sword game.

My problem is: when there is only one dragon in game, the game works great. You can play it here: https://db.tt/q1ORicv2.

But when there are two dragons, it does not matter which one I hit, the two flash and die even if one was untouched. You can see the capx here (it has platform+ installed): https://dl.dropboxusercontent.com/u/106 ... arian.capx

Image

Image

Please, help!
B
7
S
1
Posts: 11
Reputation: 449

Post » Sun Dec 21, 2014 1:19 am

Right click on Draco and select "clone object type". Don't use ctrl+drag.
B
6
S
1
Posts: 24
Reputation: 448

Post » Sun Dec 21, 2014 1:24 am

When you test a condition in construct -- did foo collide with dragon? -- any actions you take within that event only affect the instances that fulfill that condition -- the dragon that was hit.

However, when you call a function, the function itself doesn't know anything about the condition that led to it being called.

Now, you can tell the function, but that requires passing it some data that allows it find the instance again. This is called the uid. You feed this to the function by passing it as a parameter, and you select the object by 'picking' it, using the condition pick by uid within the function.

An easier way of going about this, in most cases, is to use families to test for collision events, allowing you to minimize redundant events, while still having multiple object types.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Sun Dec 21, 2014 7:28 pm

TiAm wrote:Now, you can tell the function, but that requires passing it some data that allows it find the instance again. This is called the uid. You feed this to the function by passing it as a parameter, and you select the object by 'picking' it, using the condition pick by uid within the function.

An easier way of going about this, in most cases, is to use families to test for collision events, allowing you to minimize redundant events, while still having multiple object types.


Thanks, i will try that. Thank you very much.
B
7
S
1
Posts: 11
Reputation: 449

Post » Sun Jun 05, 2016 6:10 pm

Hey I know I'm years late but could you go into detail how you would pass the UID into a function and have it pick the right instance. I'm having the same problem, I tried doing what you said @TiAm but it didnt work, so i must be doing it wrong. Please help
B
6
S
1
Posts: 46
Reputation: 476

Post » Mon Jun 06, 2016 12:49 am

Here you go another user had same problem today

http://www23.zippyshare.com/v/Q6nvlYcM/file.html

Press right arrow on computer keyboard to move right and collide with the circles. The circles will be destroyed only when you collide with them. Have fun only one line of code!!
Check out my awesome Android Game releases https://play.google.com/store/apps/deve ... ames&hl=en
B
38
S
18
G
24
Posts: 682
Reputation: 16,615


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests