Hello, I have a 2D mobile game, where I have a fast and small bullet Rigidbody2d object. Due to tunneling the bullets can fly through the wall staticbody2d. I enabled continuous collision detection, and it fixed it, but now the enemy kinematicbody2d won't detect the bullet entering it's area2d and the bullet will just bounce of of the enemy. So I disabled continuous collision detection on the bullet and increased the physics FPS to 240hz for the tunneling to stop, but now the mobile device can't handle it. What's the solution ?

Note: tunneling happens when you have a small and fast object. Due to its speed and size, it goes from at one frame being completely behind the wall to in the next frame being completely passed the wall, so the engine doesn't consider a collision to have happened.
When increasing the FPS the chance of the bullet colliding with the wall becomes bigger. Continuous collision detection (CCD) fixes the problem by using a raycast to detect if there was something between the two frames

  • Are you using an Area2d? If so, then you may want to change how you detect collision to a raycast or set of raycast to detect the collision, as they don’t have the same issue with fast moving bodies like Area2d nodes do.

    I had to do something similar for detecting fast falls for stomp detection in a platformer game. I was using an Area2d on the feet, but it was missing collisions when the player fell too fast. Using a pair of raycasts (one each foot) fixed the issue.

Are you using an Area2d? If so, then you may want to change how you detect collision to a raycast or set of raycast to detect the collision, as they don’t have the same issue with fast moving bodies like Area2d nodes do.

I had to do something similar for detecting fast falls for stomp detection in a platformer game. I was using an Area2d on the feet, but it was missing collisions when the player fell too fast. Using a pair of raycasts (one each foot) fixed the issue.

    TwistedTwigleg
    Yes, I am using an Area2D to check for if the bullet hit the enemy. I think I'll give the bullet a long raycast2D to check for the enemy. Thanks, for the answer