0

In my Jump and Run game you don't get damage when you're are colliding into the enemy from the back but it's working when you're hitting it from it's front. I'm using a Kinematicbody2d for both the enemy and the player and an area2d for checking collision with the player. The enemy is slower than the player so if you are hitting it from the back you are slower too but you can see in the image that the colliders are not touching.

click to see the picture

1

I tried messing around with the setting or making the colliders bigger but nothing worked

vimuth
  • 5,064
  • 33
  • 79
  • 116
Oliver JT
  • 11
  • 1

1 Answers1

0

You do not need to use an Area2D to detect collision between two KinematicBodies. Use get_slide_collision instead:

for i in get_slide_count():
    var collision = get_slide_collision(i)
    print("Collided with: ", collision.collider.name)
Sonny Jim
  • 26
  • 2
  • I already tried to use get_slide_count but it has the same problem. I fixed it by using raycasts – Oliver JT Jan 11 '23 at 06:31
  • Hmm. `get_slide_collision` should work without using raycasts. Are you moving the player with the `move_and_slide()` function? – Sonny Jim Jan 12 '23 at 11:02
  • yes I'am moving the player with this function , how I said it's working fine with raycasts and I wasn't using them before. – Oliver JT Jan 17 '23 at 18:46