godot
godot copied to clipboard
Fix `move_and_slide` wall slide acceleration (3D)
When travel is high enough, keep the global position resulting from the move_and_collide call, and set the motion to the remainder from the move_and_collide call. This ensures travel is taken into account once, rather than twice.
This is also consistent with the other branch:
https://github.com/godotengine/godot/blob/2efbc6bfb3b4f49a6bc75b3d367cfe81eeddbf3a/scene/3d/physics/character_body_3d.cpp#L241-L242
Thanks to @Calinou for extra testing.
- Fixes https://github.com/godotengine/godot/issues/66249
- Fixes https://github.com/godotengine/godot/issues/74553
- Fixes https://github.com/godotengine/godot/issues/90410
For ease of reviewing: the travel is taken into account in the call
https://github.com/godotengine/godot/blob/2efbc6bfb3b4f49a6bc75b3d367cfe81eeddbf3a/scene/3d/physics/character_body_3d.cpp#L159
which passes p_test_only = false into move_and_collide:
https://github.com/godotengine/godot/blob/80c600d86b6fed05fdb35d5dd95267a8a95fe74d/scene/3d/physics/physics_body_3d.cpp#L155-L159
Thanks!
Cherry-picked for 4.2.3.