Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RigidBody2D inconsistent bounces near the junction between two squared tiles #76610

Open
Yann-Situ opened this issue Apr 30, 2023 · 7 comments
Open

Comments

@Yann-Situ
Copy link

Yann-Situ commented Apr 30, 2023


Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Godot version

4.0-stable

System information

Ubuntu 20.04.6

Issue description

A round RigidBody2D colliding near the junction of two squared tiles can result in wrong and inconsistent bounces. Typically, a RigidBody2D going strictly vertical can result in a bounce with some horizontal velocity.

Possible Related issues:

  • The issue appear with the different possible continuous_cd values, but setting it to cast_ray also induces a weird damping behavior (see also #76621).
  • The same configuration often induces tunneling.
  • RigidBody2D continuous collision detection non-functional under Cast Shape setting: #72674.
  • RigidBody2D gets stuck while moving parallel in contact with multiple floors/walls: #47148

Workaround ideas

balltest-weird-bounce.mp4

Steps to reproduce

Create a Tilemap with squared tiles whose collision shapes are full squares. Create balls (RigidBody2D with round collision shape and a high enough bounce value) and place them above a tile junction, with a small horizontal offset. Run and watch the balls bouncing.
The issue itself is inconsistent: it happens with specific physics parameters at specific positions. To reproduce it correctly, one has to play with those parameters.

Minimal reproduction project

ball-weird-bounce.zip

@yanourt
Copy link

yanourt commented Sep 18, 2023

Still relevant in 4.1.
It also makes a simple rolling ball bouncing for no reason on flat ground.
If it can't be fixed without baking I think this option deserve to be included in the Tilemap tool

@DevChimera
Copy link

Can confirm this issue on v4.1.1.stable.official (ignore gravity changes, these are triggered by keyboard) As you can see collisions seems to work weird in between tiles. (bounce is disabled on this clip, yet the ball "skips" sometimes, like it has hit something.)

output.mp4

@Paar86
Copy link

Paar86 commented Jan 13, 2024

Encountered this problem while developing my current game, where I kick a ball creature around to finish a level. The ball is implemented using RigidBody2D to make it's behavior realistic. I avoid most of the problems by prebaking the collision shapes into the tilemap but it doesn't work with slopes, which I still have configure manually in a tileset.
The bug discussed here produces several problematic scenarios, all happening because the ball hits the edge between tile and slope collision shapes.

  1. Ball gets stuck under the collision shapes.
rigidbody2d_stuck.mp4
  1. When I call the ball to my position, it can get blocked and cannot move, as it is held by something.
rigidbody2d_blocked.mp4
  1. Sometimes the ball gets crazy and teleports.
rigidbody2d_teleporting.mp4
  1. The ball bounces back when thrown as if it hits a wall.
rigidbidy2d_bounces_back.mp4

As you can see, this is rather nasty bug and I would dare to say that it should take a high priority as it can deter some Godot users from using the engine. It's not easy to create workarounds. I think I presented interesting real world situations which hopefully motivate someone to investigate and fix the problem.
Right now I cannot imagine making a game with the use of a tilemap and RigidBody2D objects, especially when using slopes. Grenades bounce back at player, movable objects get stuck on the floor... There are many situations where the bug can completely spoil the experience.

@SommAid
Copy link

SommAid commented Apr 15, 2024

I am interested in this issue has there been any updates or possible leads?

@Terratype
Copy link

still an issue in 4.2.2 would really love any sort of fix

@Calinou
Copy link
Member

Calinou commented Jun 29, 2024

If your level geometry is static, you probably want to pre-bake collisions to avoid this for now: #47148 (comment)

@Griiimon
Copy link

Griiimon commented Aug 8, 2024

Should mention that the Rapier2D plugin doesn't have this issue, and seems to be on its way to become the overall better choice for 2D physics, like Jolt has become for 3D.

Rapier2D plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants