godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix delayed transform updates for kinematic bodies in Jolt Physics

Open Kaleb-Reid opened this issue 2 weeks ago • 3 comments

https://github.com/godotengine/godot/pull/109086 fixes the issue in https://github.com/godotengine/godot/issues/76256 in GodotPhysics2/3D. This pr fixes the same problem, except for Jolt Physics.

I'm not very familiar with the physics servers but this seems to work. I don't know why I have to set kinematic_transform as well, but if I don't then the transform gets set back at some point.

Kaleb-Reid avatar Dec 06 '25 02:12 Kaleb-Reid

This PR will essentially turn every kinematic body into a static body, since you're setting both the "from" and "to" transforms to be the same value, meaning the linear/angular velocity of the body will always be zero and thus any collision response elicited by it will no longer be correct.

I've put up another PR which instead changes kinematic bodies to always return kinematic_transform instead of its actual transform: #113712

mihe avatar Dec 07 '25 14:12 mihe

@mihe I see the issue now you are describing with this pr. Unfortunately, your pr does not help my use case with regards to the problem because I actually need the body to move in the physics server. I made an mrp to help show my specific problem. I want to move an area at the same time as a kinematic body and prevent it from leaving the area.

Kaleb-Reid avatar Dec 07 '25 23:12 Kaleb-Reid

I want to move an area at the same time as a kinematic body and prevent it from leaving the area.

Right, yeah, that will indeed not be solved by #113712. The only real solution to that would be to introduce some new method that lets us actually distinguish between moving and "teleporting" a kinematic body.

We could perhaps take inspiration from the Node.reset_physics_interpolation() method (which sort of achieves the same thing) and have a method that "resets" the transform of a kinematic body to be the same as its desired/target transform (i.e. kinematic_transform in the Jolt implementation).

mihe avatar Dec 08 '25 13:12 mihe