godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.75k stars 21.12k forks source link

CharacterBody3D with capsule collider stuck on edge of ramp with move_and_slide() #92347

Open NovaDawn999 opened 5 months ago

NovaDawn999 commented 5 months ago

Tested versions

System information

Linux, Windows 11 Vulkan(Forward+)

Issue description

When moving a CharacterBody3D with a CapsuleShape3D with move_and_slide(), it gets stuck on the edges/top of ramps. This is likely a repeat of #79542 and the project file provided is the same.

Steps to reproduce

Move CharacterBody3D with a CapsuleShape3D up a ramp. Will either:

  1. Act as intended, running off the edge (rarely)
  2. Get stuck at the top edge, treating it as a wall (often), unintended.
  3. Get stuck or snap character to the top edge of the ramp (often), unintended.

Minimal reproduction project (MRP)

capsule_collision.zip

rburing commented 5 months ago

It is interesting that the linked issue mentions there is no issue with a sphere shape. Can you test with a capsule shape such that its height is twice the radius (so it effectively becomes a sphere)? If there is a difference in behavior then we should be able to track it down.

(I would test it myself but I'm on mobile right now.)

NovaDawn999 commented 5 months ago

The behavior does indeed change when the capsule's height is twice the radius. It will freely pass the edge fixing condition 2.

Condition 3 doesn't happen either, however a slightly different snapping does occur: There's a snapping effect that takes place when passing the top edge. If the center of the capsule is left of the leftmost edge, when traveling over the ramp, the capsule will snap to the right, causing the center to align with the leftmost edge of the ramp. This also happens on the right side. Not sure if this behavior is related or intended.