0 votes

I'm experience a freeze in the godot physics engine (both bullet and GodotPhysics). I made a very simple example to show the issue:

https://github.com/marhov/godot/tree/main/freeze

just clone the repo and run the "Destination" scene. Use keyboard arrows up and down to move. The issue can be reproduced by first press forward and then backward. Then wait for a couple of seconds and the picture will freeze. The freeze happens when the rigid body is moving very slow or not at all and is very easy to reproduce.

Godot versions: 3.1, 3.2 and 3.4 tested and all with same behavior

Godot version 3.4.2.stable.official
in Engine by (15 points)
edited by

1 Answer

+1 vote
Best answer

Either set sleeping to false in the input events or use _physics_process instead of _integrate_forces to add the force. You could also set can_sleep for your Player to false. Whatever makes most sense for your game.

This is because, when not moving for a while, RigidBodies are sleeping. If a body is sleeping, _integrate_forces won't be called. You can verify this by looking at the remote scene tree and watch the sleeping property change from false to true once the player stops. In fact, if you wait long enough before pressing up or down, it won't even move on the first key press. This is intended behavior and helps with performance.

by (1,147 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.