wareya / GodotStairTester

Test project for stair-stepping in Godot 4
Creative Commons Zero v1.0 Universal
17 stars 2 forks source link

Cylinders vs AABB? #5

Open Skaruts opened 11 months ago

Skaruts commented 11 months ago

Are there practical differences between cylinders and AABBs? I've been playing around with this for a while, and they both seem to behave pretty much the same all around.

I noticed they also both had the same points of failure here and there with a lower speed (with or without jolt), which seems to disappear with the "skipping hack", but I'm not sure.

I was now meaning to try to port this over to my project, but I'm undecided about whether to use cylinder or a cuboid.

wareya commented 11 months ago

AABBs will never glitch out on axial geometry, but will consistently glitch out trying to climb onto ramps that are rotated at certain angles. This is because when the sideways collision trace searching for the open space above the stair is executed, it ends up in a location where the bottom edge of the AABB touches the angled edge of the side of the ramp, and the contact plane between those two edges is steep enough to count as a wall instead of a floor. This goes away at very low framerates, because the trace goes far enough to pass over the edge entirely, allowing the bottom corner vertex of the AABB to contact with the ramp's plane instead. If you never use ramps, only staircases, then this doesn't happen.

With cylinders, the same thing happens, but it no longer depends on the rotation of the ramp, so it's more consistent and happens for a smaller part of the ramp.

The skipping hack works by trying a second stair-stepping test with a fixed horizontal distance instead of one based on the movement speed. That's why this goes away if you turn on the skipping hack.

Skaruts commented 11 months ago

I see. I was actually noticing right now that boxes do fail more at certain angles. I noticed it after I made this:

char_controller

So I guess I'll be using cylinders with the skipping hack on. :)

Skaruts commented 11 months ago

It can't jump when walking into a wall, though.

Anyway I ported the controller into my project, but for some reason its having weird problems with a set of stairs. I can't tell why. In the testing level it never fails. I've even brought my map's geometry into the testing level (exact copy/paste in trenchbroom), and it doesn't fail there. In both cases I'm using cylinder with hack on.

stairs

The weird things are:

I haven't changed many things in my project, but I'm backporting my changes into the test project to see if it fails. So far it didn't, but I'm not sure if I forgot anything.

wareya commented 11 months ago

If it works in the test map but not the real map, it might be collision margin values or a slightly non-uniform object transform or something. That, or, it could be the low ceiling.

Skaruts commented 11 months ago

I think I found something. It seems to be related to negative Y coordinates. My stairs were below zero Y, so I moved the map up, and it stopped failing. I moved my test map down and then it started failing.

I unzipped a fresh copy of your original project, and as soon as I moved the map below zero it also started having trouble with the stairs.

wareya commented 11 months ago

Thanks for the diagnosis, I'll check it out when I have some free time.