Collision Detection

Get help using Construct 2

Post » Sun Dec 02, 2012 12:48 pm

Hi,

I'm trying to make myself familiar with Construct 2 so I tried to clone the game DiveKick. It feels pretty easy at first and I've run onto some bugs with but I sorted them through reading posts on the "How do I...".

Now here's the issue I've run into. Let's say Player A successfully divekicks Player B. Instead of counting the counting the score for Player A, it adds to Player B. It's having trouble determining which sprite actually hits the other sprite.

What I did first is compare the "Y" axis. It works fine for this specific game. But what if I'm to build a real fighting game. Does collision detection have something to do with zorder?

Any idea how to let the code know which sprite is actually doing the hit?
Let me know if it sounds confusing.

Thanks!!!
B
3
Posts: 2
Reputation: 429

Post » Sun Dec 02, 2012 9:39 pm

The 'on collision with' command Picks the Object that has the Collision. An easy way would be to use different sprites for each player:

If Sprite1 Collision with Sprite2 then...
Sprite1.Health = Sprite1.Health - 10
Sprite2.Score = Sprite2.Score + 1


even if you have 10 Sprite1 and 10 Sprite2 it would pick these exact two.
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Mon Dec 03, 2012 1:33 am

Collisions are only concerned with whether the object collision polygons are overlapping. They are not affected by Z order or anything else.

In a fighting game you'd need to apply your own logic to collision events, such as: if colliding and player A is attacking and player B is not blocking, hurt player B; else if player B is attacking and player A is not blocking, hurt player A, etc.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon Dec 03, 2012 2:31 am

Thanks for the response!
Yeah, I guess this is where something like hit priority and character blocking takes place.

B
3
Posts: 2
Reputation: 429

Post » Tue Dec 04, 2012 5:35 am

I finally got my collision detection working, but I cant get my player box to knockback after being hit.
B
32
S
4
Posts: 406
Reputation: 3,221


Return to How do I....?

Who is online

Users browsing this forum: h1k3, Unconnected and 0 guests