State Machine Setup for 2D Platformer Character ~ Godot 4 GameDev Tutorial
Chris' Tutorials
Break down a complex character into more managable states that run selective code and can transition into each other while controlling animations through AnimationTree and the playback travel function. This is one example of how you can structure a character for a platformer character to scale up to having many animations and different rules for how the character moves around your Godot 4 game world.
Use Part 1 End Project (below) as the Starting Point for This Tutorial to Follow Along
Download Project https://www.patreon.com/posts/godot-4-quick-80723131 Art Pack Used https://anokolisa.itch.io/sidescroller-pixelart-sprites-asset-pack-forest-16x16 Part 1: https://youtu.be/43c-Sm5GMbc
➣ Downloadable Assets, Video Courses, and Other Places to Follow Me https://linktr.ee/ChrisTutorials https://www.patreon.com/christutorials https://chris-tutorials.itch.io/
00:00:00 - What to Expect 00:01:29 - Starting Point 00:03:12 - Download in Description 00:03:25 - Add Nodes (Sprite, AnimationTree, AnimationPlayer) 00:04:26 - Idle Animation in Animation Player 00:09:10 - Run Animation 00:10:56 - Move BlendSpace1D 00:13:16 - Setting Animation Parameters 00:17:20 - Facing Direction 00:18:04 - Removing Animated Sprite References in Player script 00:19:48 - Setup State Machine 00:20:54 - Setting Up State Scripts 00:23:31 - Get States in State Machine 00:25:47 - State Can Move 00:29:58 - Jump from Ground State 00:35:12 - Change from Ground to Air State 00:37:15 - State OnEnter and OnExit 00:40:04 - State Debug Label 00:41:49 - Exit Air State to Ground State 00:44:12 - Double Jump from Air State 00:47:48 - Reducing Gravity for More Floaty Characters 00:48:19 - Jump Animations in Animation Player 00:51:46 - Animation Tree Setup 00:54:12 - Travel Tree through Playback 00:57:49 - Landing State 01:01:43 - Switch to Air when Not on Floor 01:02:37 - Player Script Cleanup 01:04:02 - Animation Position Offset due to Sprite Centering 01:05:37 - Wrapup ... https://www.youtube.com/watch?v=fuGiJdMrCAk
182327572 Bytes