Thanks to visit codestin.com
Credit goes to medium.com

Sitemap
CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Making a basic finite state machine (Godot4/C#)

Let’s discover how to implement a simple FSM in Godot!

17 min readSep 25, 2023

--

Press enter or click to view image in full size

State machines are one of the go-tool for game devs when creating AIs, or object behaviours. And, in fact, it’s not that complicated a pattern!

So, in this tutorial, let’s talk about how to make state machines in Godot 4 and C# using a hierarchy of nodes :)

However — we’re not actually going to make a character today. Rather, we’re going to focus on a simpler and less studied example, but that’s just as important, because it demonstrates how state machines can also be useful to environmental prop — we’re going to create a basic traffic light!

Press enter or click to view image in full size

I know, might not sound like much; but trust me, it will teach us a lot, and it’s actually just one proof of the fact that your game environments should live and breath, too, even though they contain “inanimate” objects ;)

Of course, if you want to get this basic traffic light 3D model I made or the code for this tutorial, don’t forget to check out the Github repo with all my Godot tutorials over here :)

--

--

CodeX
CodeX

Published in CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Mina Pêcheux
Mina Pêcheux

Written by Mina Pêcheux

I’m a freelance full-stack web & game developer. I’m passionate about topics like CGI, music, data science and more! Find me at: https://minapecheux.com :)

No responses yet