godotengine / godot

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

Character3D capsule collisionShape3D getting stuck in trimesh heightmap planes #69131

Closed StoreBoughtRocketGames closed 1 year ago

StoreBoughtRocketGames commented 1 year ago

Godot version

4.0 dev Beta 6

System information

Windows 10, Vulkin

Issue description

My Character3D player is getting stuck on trimesh collision surfaces, basically anything that isn't a flat trimesh plane. I tried to make a heightmap in Blender, and trimesh the surface to use as a landscape, and found it was basically unusable.

It happens with capsule shapes, and (I believe, but need to confirm) also happens with cylinder shape collisions, but seems to be not happening at all for boxShape collisions. I almost can't move at all when I use a capsule collision shape. There may be some relation to issue #46712, but this seemed different enough to warrant a new bug report. I searched for this issue, and couldn't find anything, so hopefully I'm not duplicating a known issue.

Steps to reproduce

Run around terrain (ASDW), and you should get stuck almost right away. To get unstuck, you can push spacebar to jump, which you can use to move around the level. Change to a boxShape, and the issue goes away. I think the issue is also present to some extent with the cylinder collision shape, but it happens less frequently.

Minimal reproduction project

TestProject.zip

StoreBoughtRocketGames commented 1 year ago

This doesn't occur in Godot 3.5.1. So, most likely a Godot 4.0 only issue. I'm able to run around in the same scene just fine. Although, I get the capsule collision clipping through the terrain, it doesn't get stuck. So there is some weirdness with the capsule collision in 3.5.1., but it doesn't make it unplayable.

Minimal reproduction project

TestProject_3_5.zip

snougo commented 1 year ago

I got same issue and it caused by ConcavePolygonShape3D, when I used ConvexPolygonShape3D, there is not such problem at all.

https://user-images.githubusercontent.com/64188282/203952212-6094e05a-75ff-4125-a30a-d3824b251bf3.mov

https://user-images.githubusercontent.com/64188282/203952316-1f97f02c-14a6-4a02-bda7-fe10fe29d420.mov

Gamepro5 commented 1 year ago

This seems to be due to the same underlying issue as https://github.com/godotengine/godot/issues/69137

It seems to be a tracked issue, but hasn't been fixed yet despite it's severity. I suspect that the the issue of trimesh edges causing incorrect collision normals causes

https://github.com/godotengine/godot/issues/46712 https://github.com/godotengine/godot/issues/69131 https://github.com/godotengine/godot/issues/69137

There are probably more I'm missing.

StoreBoughtRocketGames commented 1 year ago

Any idea why the behavior is different from 3.5.1 to 4.0? I haven't looked through engine code myself as I'm not familiar. But, I'm fairly certain someone could figure out how to fix it if they compared the code from 3.5.1 to this one. Probably not a good use of my time personally since I've never contributed, nor compiled the engine.

Not sure if you want to leave this issue open or not since there do appear to be other reports out there if the same thing. The only new info this one has is the behavior difference from 3.5.1 to now. I'd be fine if you wanted to close it out as a duplicate.

josheb commented 1 year ago

I'm seeing this sometimes with a capsule shape. The FPS template in the repository is my starting point. godot_physics_1.webm Axis alignment seems to be a factor. If I run straight at it it will stick much of the time, but if I rotate a little it slides past.

rburing commented 1 year ago

Related to (or maybe even the same as) https://github.com/godotengine/godot/issues/69683.

rburing commented 1 year ago

The main problem in the minimal reproduction project is the non-uniformly scaled capsule collision shape on the character. Since 4.0 beta 15 the editor (and the class reference) warns against using non-uniform scaling for 3D physics objects (see https://github.com/godotengine/godot/pull/67847), since such transformations can't be supported properly by the physics engine.

Using a capsule collision shape with uniform (1, 1, 1) scale (and the radius and height updated to approximately match the previous transformed shape) fixes the issue: TestProject-uniformscale.zip.