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

RigidBody gains momentum with each collision when bounce = 1 (both 2D and 3D, Bullet and GodotPhysics) #52550

Closed
Tracked by #45334 ...
udit opened this issue Sep 10, 2021 · 3 comments · Fixed by #55313
Closed
Tracked by #45334 ...

Comments

@udit
Copy link

udit commented Sep 10, 2021

Godot version

3.3.3.stable

System information

Windows 10

Issue description

Current behaviour: When RigidBody2D's bounce is set to 1, it keeps gaining more speed every time it bounces off a StaticBody2D, when angular and linear damp are set to 0.

Expected behaviour: RigidBody2D should conserve momentum and bounce back with same speed.

Steps to reproduce

Run the main scene in below minimal reproduction to observe that RigidBody2D keeps gaining more speed with each bounce.
output

Minimal reproduction project

RigidBody2DTest.zip

@Calinou
Copy link
Member

Calinou commented Sep 10, 2021

Out of curiosity, can you (or anyone else) reproduce this issue in 3D with Bullet and GodotPhysics?

@udit
Copy link
Author

udit commented Sep 11, 2021

Did a test with RigidBody and the bug exists both in Bullet and GodotPhysics.

Body keeps gaining momentum with each bounce when linear and angular damp is set to 0. If you set both damps to 0.1 (which is default) then,

  • GodotPhysics: RigidBody bounces back to the same height
  • Bullet: RigidBody bounces back to anywhere between a small range around the drop height

Minimal reproduction project for 3D: RigidBodyTest.zip

@Calinou Calinou changed the title RigidBody2D gains momentum with each collision when bounce = 1 RigidBody gains momentum with each collision when bounce = 1 (both 2D and 3D, Bullet and GodotPhysics) Sep 11, 2021
@Calinou Calinou removed the topic:2d label Sep 11, 2021
@Xrayez
Copy link
Contributor

Xrayez commented Sep 23, 2021

Biased velocity which is used to separate bodies in order to resolve interpenetration could contribute to gain in momentum. I'm currently developing my own physics engine and get the same results when restitution (bounce) is set to 1.0.

Increasing Engine.iterations_per_second to values like 300 helps to minimize this gain in momentum, and decreasing it to 30 makes it even more dramatic. So I guess this is also an error accumulated from integrating velocity/acceleration over large or small delta time (the smaller, the less error).

I'm really not sure if there's an efficient way to resolve this, but according to other engines/implementations, it seems to be a common limitation. Perhaps a better integration scheme could be incorporated, but that would be at the cost of performance.

CCD could also help this perhaps, but it's not working: #9071.

Body keeps gaining momentum with each bounce when linear and angular damp is set to 0. If you set both damps to 0.1 (which is default) then,

  • GodotPhysics: RigidBody bounces back to the same height

Perhaps this is one of the reasons why damp is set to 0.1 by default, to cover up those issues.

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

Successfully merging a pull request may close this issue.

4 participants