8:50 bro, you didn't edit it out. ☠😂 Great video btw. Ive always been scared of dealing with anything inside a { } or [ ] but this video made it really simple. I appreciate it man
A good thing about doing it this way, is that you can expand the list - *backwards*. That is, imagine you have firetype double and triple, and only later decide to have a single-shot fire type too; you can put it in the enum list, *before* the double, and because everything is using the enum, it breaks nothing at all. You can also do things like have an enum and an array at the top of your file that are in parity, and use the enum as an index for the array, so that you can always just quick-access the correct array element from another class no matter whether you've changed things. I found that really useful when making some temporary debugging tools.
Thanks! I record them in batches then release them regularly, like a TV season. There may be gaps between seasons, but I've got lots of ideas and plans for future videos.
Why do your enums show the string name in the inspector but mine show int? For example your Fire Type enum shows as single. But when I try to replicate that I only see 0?
I was just making UI prototype that has a bunch of toggles and moves a few frames of some sprites with one button, this seems a lot better way to select from a list of things.
I’m a beginner so forgive me but can someone explain why the index of an enum value would ever be needed if enum values are constant and hard coded? When would I ever not reference it by name? Also follow up question: wouldn’t directly setting the integer value (do you even call it the index?) functionally turn your enum into a dictionary of constants? Edit: kind of realizing the nature of my question is really just what use the integer values have? This video is immensely helpful but it only contains an example of using enums as mini state machines and I can’t help but feel there’s more to them, possibly?
I found enum a few days back, using it for game state, really needed to know how to access it globally across scenes - thanks. I now know class_name :)
When you access fire input though in the bullet your just accessing the enum which is a const so that wont change. You need to access the export variable that you made to actually check some logic. But how do I access a export variable from another script?
I'm glad to see people teaching others but it is sad to see such poor programming practices being taught. Having an enum with each amount of times fired is just poor use of an enum. Your better off using the enum to choose if its single fire, burst, or full auto and if its on burst have an int saying how many time to fire instead of having if statements and an enum for each amount of bullets to be fired. Also making multiple vars for each bullet is kind of a waste when you could just put all that repeated code into a for loop for the bullets and only have to write that stuff once.
if you want to print an enum so you can read the name instead of seeing the number, print_debug(FireState.keys()[fire_state])
Thanks for the tip! That's fantastic.
This is the first I've heard of upper snake case being called 'screaming snake case' - I love it!
In case anyone is wondering, at 8:37 you have to reload the project to show the documentation
At 8:44 the doc string isn't being added to the inspector because there are outstanding syntax errors that have to be resolved first.
Bonus points for teaching me about Ctrl+D
8:50 bro, you didn't edit it out. ☠😂
Great video btw. Ive always been scared of dealing with anything inside a { } or [ ] but this video made it really simple. I appreciate it man
A good thing about doing it this way, is that you can expand the list - *backwards*. That is, imagine you have firetype double and triple, and only later decide to have a single-shot fire type too; you can put it in the enum list, *before* the double, and because everything is using the enum, it breaks nothing at all.
You can also do things like have an enum and an array at the top of your file that are in parity, and use the enum as an index for the array, so that you can always just quick-access the correct array element from another class no matter whether you've changed things. I found that really useful when making some temporary debugging tools.
I finally understood enums thanks to you
Thank You for showing this. You mad it informative and easy to get
Thank you! simple and to the point.
Brett your tutorials are invaluable. Thank you for contributing to godot community
Thanks so much for the support and kind words!
Very helpful as always. And wow you make a lot of videos fast!
Thanks! I record them in batches then release them regularly, like a TV season. There may be gaps between seasons, but I've got lots of ideas and plans for future videos.
This is a really well made tutorial! Thank you!!
this is a great advice! First we make it work, than we polish
Why do your enums show the string name in the inspector but mine show int? For example your Fire Type enum shows as single. But when I try to replicate that I only see 0?
It helped me a lot. Thank you!
Thanks, this is exactly what I needed
I was just making UI prototype that has a bunch of toggles and moves a few frames of some sprites with one button, this seems a lot better way to select from a list of things.
the fainting is actually funny because it gives emotion to the mistake.type
I’m a beginner so forgive me but can someone explain why the index of an enum value would ever be needed if enum values are constant and hard coded? When would I ever not reference it by name?
Also follow up question: wouldn’t directly setting the integer value (do you even call it the index?) functionally turn your enum into a dictionary of constants?
Edit: kind of realizing the nature of my question is really just what use the integer values have? This video is immensely helpful but it only contains an example of using enums as mini state machines and I can’t help but feel there’s more to them, possibly?
I found enum a few days back, using it for game state, really needed to know how to access it globally across scenes - thanks. I now know class_name :)
When you access fire input though in the bullet your just accessing the enum which is a const so that wont change. You need to access the export variable that you made to actually check some logic. But how do I access a export variable from another script?
I'm glad to see people teaching others but it is sad to see such poor programming practices being taught. Having an enum with each amount of times fired is just poor use of an enum. Your better off using the enum to choose if its single fire, burst, or full auto and if its on burst have an int saying how many time to fire instead of having if statements and an enum for each amount of bullets to be fired. Also making multiple vars for each bullet is kind of a waste when you could just put all that repeated code into a for loop for the bullets and only have to write that stuff once.