Collisions with multiple objects same spot

Get help using Construct 2

Post » Thu Jul 11, 2013 10:05 am

Hello!

I am trying to do a game like Stick War 2/ Age War 2 but I have lots of problems with collisions.

Can someone show me a good way to make collisions work well. Now I got a collisions but I got problems. When there is more than one enemy/player in the same spot and gets hit. All of them gets hit.

Example:

2 archer in the same spot. 4 shots collision with them and both die.

Here is the capx.
https://dl.dropboxusercontent.com/u/7290053/CaveLab/Defense/Defense.capx

I also will be happy if you want give me some advice of how I am coding it.

Thanks in advice.

Peret
B
14
S
4
G
1
Posts: 42
Reputation: 1,775

Post » Thu Jul 11, 2013 11:26 am

To reproduce the anomaly on the collisions.
Let the CPU spawn a few "archers"(3 is okey). Then spawn one of your archers with the icon on the bottom.
And look how the top 3 CPU "archers" will die with only 4 shots. This not should happen.

B
14
S
4
G
1
Posts: 42
Reputation: 1,775

Post » Thu Jul 11, 2013 3:08 pm

A simple trick is to set the bullet to be invisible on the collision, and also add a check for visibility to the 'On collision' check. Since only the first target checked will have the bullet still visible, only one is eliminated.

SingleCollisionTest_r132.capx
ImageImageImage
B
71
S
19
G
179
Posts: 3,478
Reputation: 102,672

Post » Fri Jul 12, 2013 8:56 am

@blackhornet Thanks for your time. I tested this but it doesn't work because my enemies have an instance variable of Health, not only one hit.

I think my problem is that when a "shot" hits a "human". I don't know how to do it that only applies this in the "human-Health" that has collisioned not all.
B
14
S
4
G
1
Posts: 42
Reputation: 1,775

Post » Fri Jul 12, 2013 1:17 pm

Try 'For each' statement. It a bit resource consuming and tricky though.
B
13
S
6
G
3
Posts: 20
Reputation: 4,121

Post » Fri Jul 12, 2013 2:59 pm

The same logic applies for health:

SingleCollisionTest_withHealth_r132.capx

'For each' won't help in this case as 'On collision' is called for each collision already - only one target is picked at a time. You have to do something to have the subsequent calls blocked.
ImageImageImage
B
71
S
19
G
179
Posts: 3,478
Reputation: 102,672

Post » Fri Jul 12, 2013 3:11 pm

@blackhorent I can't test it out until monday. It seems it can work on my game. On monday I will tell something about it.

Thank you again

@MagicTofu Thanks for your time.
B
14
S
4
G
1
Posts: 42
Reputation: 1,775

Post » Mon Jul 15, 2013 8:28 am

@blackhornet I just tested and it's working! :) Thank you very much.
B
14
S
4
G
1
Posts: 42
Reputation: 1,775


Return to How do I....?

Who is online

Users browsing this forum: Alex Bryant, mercuryus, Moordhuis, omnipaws, sirheimer, tarek2, zenox98 and 12 guests