Finite State Machines in Godot | Godot Starter Kit FSM

preview_player
Показать описание
Video Content:
----------------------------------
0:00 - Intro
1:01 - State Class
2:51 - FSM Class
5:25 - Signals
6:08 - Summary
6:22 - Transitions
7:52 - Force Change State
9 :00 - Outro
------

In this video I discuss how FSM's work in general, sort of the typical layout but also more specifically how it's set up in my Godot Top-down starter project

The second part of the video focuses more heavily on the project itself, its transitions and signals and so on

I hope you learned something or gained some insight, thank you for watching!

Github:
Asset library:

My second, somewhat simpler starterkit:

You can buy me a coffee to make me code faster at:

#coding #learning #godot #godotengine #gamedev #gamedevelopment
Рекомендации по теме
Комментарии
Автор

I have probable looked up about 8 videos, read a few articles and asked both chatgpt and gemini to explain to me in detail how Finite State Machines work, and your video did it best. Thank you!

ilivetruth
Автор

Лучший урок по стейтам, что я видел. Не только дал удобную ФСМ, но ещё и очень просто объяснил как всё это работает и зачем нужна каждая строчка. Блин, если бы все на ютубе объясняли как ты - я бы уже закончил свою игру. Спасибо!

kostanislaw
Автор

This is a very useful video for all beginners, not just godot users! It explains exactly what a FSM is and how it should work, not to mention it is well edited and easy to understand. Good job, keep up the good work :)

philldev
Автор

tysm for this tutorial, ngl the code here is like identical to a tutorial about the same subject from Bitlytic (not sure if that's intentional or a happy accident) but like, you actually explain it in a thorough and easy to understand way? Bitlytic skims over so much important info for beginners but you hit the nail right on the head with the explanations, super comprehensive and easy to follow, tysm again king ily <3 <3 <3

locke_d
Автор

You are a godsend! Explanations were short concise and easily understandable.
Thank you from the bottom of my heart! I can't wait for more!

armored_gore
Автор

It's been 30 years and I finally understand. Thank you!

anthonygill
Автор

I'm nearly done with porting this to Godot 3, thank you for explaining it clearly.

kloa
Автор

I had a project where I tried a sort of state machine but used timed animations that would trigger follow up states. I ran into issues when trying to do a forced state while animations were still running. Im pretty sure a more defined approach like what you have here would have sorted out my issues, being able to end animation delegates in the current state Exit method before killing the object. Cool explanation, thanks.

curtiss
Автор

Just found your channel and I fell in love with it

offlinemoe
Автор

This looks like a very organized way to do it. I just throw all of the states in a switch function in my player’s script, and each state gets its own function, and then each state’s function has logic for the other states it can switch to… I like this idea though!

Rawbherb
Автор

Lovely intro on how FSM work, as well as separating them all out to a manager function. I believe this is how Godot is meant to be programmed.

hensola
Автор

Where do you attach the script for the initial state class definition?

skaterjoe
Автор

Fantastic video! Very high quality and helpful, thank you!

PaperMouseGames
Автор

Where/When the state_transition is emitted?

ykyjohn
Автор

Thanks for this very comprehensive tutorial about FSM. 🤗

Altaryum
Автор

i dont know how i should transition the state for my enemy. so it detects when the player entered his territory and then it should switch to chase state. What do I have to put in there?

# In the Idle State:

func
if body.is_in_group("Player"):
FiniteStateMachine.change_state(State, "BaseNPCChaseState")



doesnt work

tsKayne
Автор

Any tips on how to combine this with composition (stuff like making components and composing entities from them, like VelocityComponent, HealthComponent, WanderAroundComponent, etc)

fuzzy-
Автор

Is this the same as Finite State Automata?
Where you have a Deterministic Finite Automaton, DFA, a Non Deterministic one, NFA, an Epsion Non Deterministic one, e-NFA, and you work on reducing whatever automata you have into a minimal deterministic one?

I took this as part of an introductory course to compilers and it seems awfully similar

fuzzy-
Автор

I don't think I actually need a state machine but i want to learn them, this is like the third video I've watched on them and they haven't become any less intimidating. Question about your force state function, how exactly can it break your game? Aren't exit functions meant to prevent the state machine from breaking or have I misunderstood their purpose? Oh wait the problem is with decentralised state machines, right? Since each state is only accounting for it's own transitions and trying to transition to something it doesn't know how to could break things? I don't know...

cheesymcnuggets
Автор

:( State_Machine.gd:16 - Parse Error: Cannot call non-static function "Enter()" on the class "State" directly. Make an instance instead.

DariusK-fe