# Approaches ## Simple If you have no need for stairs the built-in `move_and_slide` function handles tiny obstacles and ramps quite well, particularly when combined with capsule shaped character colliders. ## Separation Rays The recommended solution by the Godot team, however a large number of people have pointed out significant bugs in the implementation which affects actual gameplay movement. They also do not work with the [[Jolt Physics]] addon, which many people say is a requirement for serious 3D development in Godot. ## Physics Test Body # Shapes ## Capsule Unity, Unreal, and Godot all favor capsule shaped character colliders because it simplifies collision detection but many developers chafe at this because of the downsides of this shape - particularly on edges. > Capsules reduce the demand for complicated slide algorithms but behave unreliably at platform edges \- Footnotes for the Future ## Cylinder Many people consider this the ideal shape. > A cylinder's flat bottom creates reliable platform edge behaviour, and the curved edge creates reliable wall slide behaviour \- Footnotes for the Future Some say that this shape was broken in 4.0, not sure if it was fixed. ## Box This is the classic shape used by many games in the 90s. > A cube's flat bottom creates reliable platform edge behaviour, and variability in closest wall distance based on wall angle is hardly noticable, but slide direction behaves unreliably where walls join \- Footnotes for the Future # Potential Issues Things that need to be checked for and tested. - Drop off ledges while moving slowly - in one iteration of my character controller it was not possible to walk off flat surfaces at all - Drop down stairs without noticeable fall time - This happens because the lateral momentum is too high compared to the step depth, typically games expect characters to be able to run down stairs faster than is possible in real life and have them stick to the stairs rather than float off - Crouching should not ## Steps Climbing *up* steps and onto low obstacles, sills, and ledges without jumping (or other explicit triggering) is one of the hardest problems in game development with innumerable words written on the subject. - The final stair should not launch the character upwards - It should be possible to step up onto a slightly higher surface without jumping - Characters should not end up stuck in the ceiling when walking onto steps with low headroom - Characters should not be teleported high up when walking up to a wall - Steps with gaps at the bottom (like a lowercase letter `n`) should not prevent characters from stepping onto them - Steps next to walls should allow the character to slide along the wall without getting them stuck - Step functionality should not interfere with ramps - Characters should not be able to anomalously walk up highly angled surfaces or walls as a result of step functionality - Characters should not accelerate noticeably as a result of stepping up - Characters should be able to walk down steps that they can walk up and vice versa # Refinements ## Coyote Time Allow the player to execute a jump for a short time after starting to fall. This allows a bit of wiggle room to compensate for the lack of kinesthetic awareness or realistic foot positioning when jumping off of ledges, such as between platforms. ## Jump Buffering Execute a jump after landing that was initially triggered while still in the air. Like coyote time, this makes a character feel more responsive and covers for minor timing issues that might be present in the game or input system. ### Timer The traditional way to do this is to set a timer after pressing jump while still in the air and if the player is detected on the ground before the timer runs out, then jump. ### Held Action If the jump button is still held when hitting the ground, immediately execute the jump. # Juice # References ## Conceptual References - [Shifty's Godot Character Movement Manifesto](https://markdownpastebin.com/?id=d9d61e67f9d64db2bd215f165b931449) (for v3.x) - [Alex’s Godot Character Movement Manifesto](http://www.footnotesforthefuture.com/words/godot-movement-manifesto/) (for 4.0) - [Collision Response: How to Climb a Staircase Properly](https://thelowrooms.com/articledir/programming_stepclimbing.php) ## Code References Specifically controllers which handle stairs, because it is perhaps the most difficult problem to solve. - https://github.com/mrezai/GodotStairs - Reddit [thread](https://www.reddit.com/r/godot/comments/194vqe2/godotstairs_a_poc_implementation_of_stair/) on it - https://github.com/JheKWall/Godot-Stair-Step-Demo - AKA `dualworlders` and `dwd_waver` - Useful test geometry - Demonstration [video](https://youtu.be/FjD-Ndx8mBk) - https://github.com/wareya/GodotStairTester - Useful test geometry - https://github.com/alexjhetherington/godot-character-controller-example/ - Doesn't implement jumping - Require [[Jolt Physics]] - https://github.com/MilkAndBanana01/godot-fps-template - https://www.youtube.com/watch?v=ykWS-39Iz1Y ## Code Examples Many of these are woefully incomplete but are useful for getting started. - https://github.com/LegionGames/FirstPersonController - https://github.com/GarbajYT/godot_updated_fps_controller - https://github.com/ExpressoBits/character-controller - https://github.com/LegionGames/FirstPersonController/blob/main/Scripts/Player.gd - https://gist.github.com/Blarfnip/32d50cdd35cbb9abd956d5bf4c7bb7d7 - https://github.com/Phazorknight/Cogito ## Godot Proposals and Issues - [Robustness and stability of physics interactions in Godot. A 4 years retrospective.](https://github.com/godotengine/godot-proposals/discussions/9646) (started [[2024-05-01]] by yosoyfreeman) - [Add automatic smooth stairs step-up and step-down for KinematicBody using move_and_slide()](https://github.com/godotengine/godot-proposals/issues/2751) (started [[2021-05-20]] by elvisish) - An absolute treasure trove of information in the comments ## Tutorials - [[Character Movement]] (generic) ```cardlink url: https://youtu.be/A3HLeyaBCq4 title: "Juiced Up First Person Character Controller Tutorial - Godot 3D FPS" description: "In this video we create a first person character controller for Godot 4 from scratch. We also add a range of game feel features including headbob, sprinting,..." host: youtu.be favicon: https://www.youtube.com/s/desktop/3db4422d/img/favicon_32x32.png image: https://i.ytimg.com/vi/A3HLeyaBCq4/maxresdefault.jpg ``` - [How To Make A Realistic FlashLight In Godot 4](https://youtu.be/9du4wUOGqnc) - This tutorial is broken in several significant ways that are hidden by the creator in the video, and I spent several hours debugging it, but it did at least give me a starting point ```cardlink url: https://www.youtube.com/watch?v=jzbgH4AMtI8 title: "How To Make A Doom Clone In Godot 4" description: "assets: https://nartier.itch.io/godotdoomcloneassetspassword: mizcourse: https://www.udemy.com/course/how-to-make-a-retro-style-3d-fps-in-the-godot-game-engi..." host: www.youtube.com favicon: https://www.youtube.com/s/desktop/e57c4f65/img/favicon_32x32.png image: https://i.ytimg.com/vi/jzbgH4AMtI8/maxresdefault.jpg ``` ## Smooth Movement - https://cohost.org/MikeWake/post/4184334-jitter-in-godot-4#comments ## Other Engines ### Source Engine - View Bobbing - https://gamebanana.com/tuts/12972 - Custom Collision - https://www.moddb.com/mods/bleachzanpakutousenshi/tutorials/custom-aabb-collision-boxes-for-an-entity ### Unity - https://github.com/nicholas-maltbie/OpenKCC