godotengine / godotengine/godot
CharacterBody3D slides off rotating AnimatableBody3D
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible with v4.3.stable.official [77dcf97d8], tested with both:
- Godot Jolt Version: 0.14.0 https://github.com/godot-jolt/godot-jolt
- Default GodotPhysics3D
- Reproducible with v4.4.stable.official [4c311cbee] using the now built-in Jolt physics.
### System information
Windows 10 - Godot v4.3.stable.official - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 SUPER - AMD Ryzen 9 3900X
### Issue description
CharacterBody3D's follow moving AnimatableBody3D platforms with move_and_slide() in _physics_process, this works great.
No matter how fast you move the platform positionally it seems to stay completely in-sync.
However things start to go wrong when you **rotate** the AnimatableBody3D. The CharacterBody3D starts to slide off from the center of rotation.
The faster it rotates, the faster the character slides off.
Is there something within move_and_slide() that doesn't account properly for rotating bodies?
Here's a video of the issue:
https://github.com/user-attachments/assets/f5f47664-3c16-408a-adba-d87ebcc99006
(the floor is the moving/rotating AnimatableBody3D, the cube above is just something static for visual reference)
### Steps to reproduce
- Create a scene with an AnimatableBody3D floor + CharacterBody3D
- Ensure that the CharacterBody3D has minimal movement/gravity within _physics_process:
```
func _physics_process(delta: float) -> void:
if !is_on_floor():
velocity.y += get_gravity().y * delta
move_and_slide()
```
- Ensure that the CharacterBody3D is not located at the exact center of rotation, a sideways-offset of Vector3(0.1, 0, 0.1) will suffice
- Rotate the AnimatableBody3D via _physics_process:
```
func _physics_process(delta: float) -> void:
global_rotation_degrees.y += 50.00 * delta
```
- Add a camera, run the scene and wait until you see the CharacterBody3D slide off
### Minimal reproduction project (MRP)
This project contains what you see in the video preview above:
[CharacterBody3D_sliding_off_rotating_AnimatableBody3D.zip](https://github.com/user-attachments/files/18768303/CharacterBody3D_sliding_off_rotating_AnimatableBody3D.zip)
Contributor guide
Research direction
Start with the minimal reproduction project and the _physics_process calls that rotate AnimatableBody3D and invoke CharacterBody3D.move_and_slide(). Reproduce the offset CharacterBody3D sliding from the rotating platform at different rotation speeds. Done means the reproduction no longer shows this unintended sliding while positional platform following remains intact.
Written by the indexing model from the issue text.
Assessment
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100