Using Enums in GDScript for Better Code in Godot 4
YouTube Viewers YouTube Viewers
3.27K subscribers
6,938 views
0

 Published On Apr 20, 2023

Enums in GDScript are a great way to manage state and limited options for variables. This video goes over how to define them, use them, and work with them in the Inspector in Godot 4. The concept is illustrated by adding a fire state to a play that handles firing one bullet or two. An anti-example is provided, then the code is refactored to show the value of enums.

Source code: https://gist.github.com/brettchalupa/...

Godot version used: 4.0

Donate as a way to say thank you: https://www.buymeacoffee.com/brettcha...
Check out my games: https://brettchalupa.itch.io/
Subscribe to my newsletter: https://www.brettchalupa.com/newsletter

Chapters
00:00 - Intro
02:24 - Counter-Example Using a String Variable
05:50 - Refactor to Using an Enum
11:10 - Referencing an Enum in Other Scripts
12:33 - Code Clean Up
14:16 - Easier Testing
15:14 - Outro

#Godot #Godot4 #GrowingWithGodot #GodotEngine

show more

Share/Embed