-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Inconsistent execution order of _integrate_forces #11925
Comments
Not sure if I understand the issue correctly, but can't it be worked around by turning "Custom Integrator" on, and calling |
In spite of its name, The problem is execution order. By default, each physics cycle, the engine will integrate forces (i.e. calculate rigid body velocities from their respective forces) and then integrate velocities (i.e. calculate the displacement of rigid bodies based on their respective velocities). This is all fine and dandy. There's a virtual method for rigid bodies called It does not. The problem is that _integrate_forces() is called after the engine integrates velocities, whereas the default force integration is called before. This seems minor, and it is, but it still throws off the physics simulation slightly. This is something I may have to dig into myself and I'm likely one of the only people unreasonable enough to care about it honestly. |
Ok, makes sense, looking at the code also confirms your theory.
|
Is this still valid in the current master branch? |
This is the code I used for testing (in 2.1.5):
If I understand the issue correctly, these 3 should output the same position at the start. b2b06dd with equivalent code behaves the same, so I guess it's not fixed. Unless I tested wrongly. |
I think my problem might be related to this issue but I'm not sure. I have the following scenario: two RigidBody2Ds (player and the ball). Player's velocity is controlled by the keyboard in I wanted to implement a kick - player can kick the ball which means setting its velocity right after the collision. For that purpose I use
I can't apply new velocity right after the collision because by the time I want do that, physics engine calculates its own velocity after collision and instantly applies it to the object. This results in a noticeable jitter when the initial ball's velocity is high but the target velocity is small. Let me know if this could be an engine thing or me doing things in a wrong way. |
Operating system or device, Godot version, GPU Model and driver (if graphics related):
v2.1.4 stable
Issue description:
The standard 2d physics step performs force integration before velocity integration. Rigid Bodies have a method binding called
_integrate_forces
that's designed to replace force integration with custom logic. However, within a standard step, the_integrate_forces
method executes after the velocity integration stage, rather than before.This is mainly a consistency issue. It can partially be worked around by inserting integration code into the
_fixed_process
method, but this can result in minor race conditions if other nodes attempt to modify a rigid body's physics parameters during the fixed physics stage.The text was updated successfully, but these errors were encountered: