Looking for a proper way to solve jumping collision issue in fighting game.

Hi, i’m currently working on a pixel 2D fighting game and i found a headache issue which is collision in jumping.

These are the situations which need to be solved(Suppose each character has a collider/colliders and rigibody attached):

  1. Jump to grounded opponent but the opponent is on your landing position. Then you stand on opponent’s head or possibly push the opponent a bit distance then slowly fall on ground. (The player is supposed to fall on the ground smoothly)
  2. Jump will be blocked once the opponent is jumping on your head.(The player is supposed to make a complete jump)
  3. Your opponent is stand at the left/right edge of the screen, you jump toward to him and stoppped on its head.(The player is suppose to land on the right of the opponent if opponent is at the left edge or to land on the left side of the opponent if opponent is at the right edge)
  4. Silimar to 3. Your opponent is jumping at the edge of the screen, and the player is also jumping toward it there.(This is the most headache part.)
    I did some tries to shift the horizontal position of the player/opponent in the above situations when collision happens, but it somehow looks not that smooth and it can’t cover all situations.(Considering the opponent can move at same time, the situation becomes more complex when only implemented simple shifting)

Hope i explained the issue clearly.
So, is there any suggestion or existing good solutions for such issue?

I’m a little confused. Posting code and/or showing an image can help us understand the issue better :wink:

Are you talking about in-air collisions? Or isn’t the character able to jump in certain situations?

Here are few things to check:
Are you checking with a raycast wether the player is grounded? Maybe use collisions layers with them if you don’t.
Are you doing physics update in FixedUpdate? If you don’t, it will cause many problems.
Is the rigidbody’s mass and gravity the same for the player and opponent?

Hi Thanks for your reply, I think i solved the issue. I have changed the collider to a capsule collider and slide both of the characters when collision occurs in air. It looks smooth now.

1 Like