godotengine / godot

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

CharacterBody3D teleports when colliding with convex edge of StaticBody3D #87521

Open iamcal opened 8 months ago

iamcal commented 8 months ago

Tested versions

System information

Godot v4.2.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3090 (NVIDIA; 31.0.15.3699) - AMD Ryzen Threadripper 3960X 24-Core Processor (48 Threads)

Issue description

I have a single MeshInstance3D containing a single StaticBody3D (which contains a single CollisionShape3D), imported from a Blender GLB, as the world. The player is a CharacterBody3D with a MeshInstance3D/CapsuleMesh and a CollisionShape3D/CapsuleShape. Movement is via the default example GDScript using move_and_slide().

When walking over convex edges, the player is randomly teleported and sometimes has it's rotation changed. This does not occur on concave edges. Jumping over the convex edge works as expected - the issue appears to be collision detection related.

This looks similar to #77051 from last year.

Steps to reproduce

https://github.com/godotengine/godot/assets/173750/ce26b7e5-0699-4bcf-9e25-a07919e688b8

Minimal reproduction project is attached

Minimal reproduction project (MRP)

FPS Bug Demo.zip

iamcal commented 8 months ago

The teleportation always moves the CharacterBody3D to somewhere along the edge being crossed, which definitely points to a math error somewhere in collision detection.

iamcal commented 8 months ago

This is happening all the way back in Godot 4.0-stable too. It's specific to this geometry, but I'm trying to further narrow down what's special about it.

VeryElusiveMoose commented 2 months ago

I faced this issue today as well, it was causing me to clip into a wall while walking on a convex surface. There is a simple work around for anybody needing a solution - look into switching your physics engine to Godot Jolt! image