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

[2D Physics] RigidBody2D breaks when on a StaticBody2D and Engine.time_scale is set to 0 #82308

Open
Stronkkey opened this issue Sep 25, 2023 · 3 comments

Comments

@Stronkkey
Copy link

Stronkkey commented Sep 25, 2023

Godot version

4.1.1 stable

System information

Godot v4.1.1.stable unknown - Artix Linux - Vulkan (Compatibility) - Mesa Intel(R) HD Graphics 4000 (IVB GT2) () - Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz (4 Threads)

Issue description

Setting Engine.time_scale to 0 while a non-sleeping RigidBody is on a StaticBody sets all Node2D properties from the RigidBody to nan. Note that this does not happend with SceneTree.paused.
2023-09-25T16:34:45,189553305+02:00

Steps to reproduce

  1. Run the MRP
  2. Press space bar when the RigidBody is on top of the StaticBody. This should set Engine.time_scale to 0
  3. The RigidBody should disappear and have their Node2D properties set to nan

Minimal reproduction project

crash.zip

@Stronkkey
Copy link
Author

Forgot to mention that only one RigidBody breaks per StaticBody. This means that if two RigidBodies are on a StaticBody, only one breaks when pausing.

@vpellen
Copy link

vpellen commented Oct 3, 2023

I think I ran into this myself when trying to do time-freeze shenanigans.
My best guess is a division-by-zero error somewhere within collision resolution, probably to do with calculating relative velocities.
If you're after a practical solution, I found that setting time_scale to the smallest nonzero float possible seems to prevent the NaNs from showing up and any movement that was still there effectively got lost in rounding process.

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

3 participants