Комментарии:
I know this video is old, but say I wanted to use the enum values as parameters for functions in the script, functions that would be referenced in other scripts. Would it be a good idea to make the enum public so these other scripts can use them for the functions?
ОтветитьThanks!
ОтветитьDo you still believe, as you say in the beginning of the video, that you should always use enums for state handling? I don't use string references I use individual classes that I attach as components.
ОтветитьReally useful I like it
ОтветитьHi! Just curious to make sure this is right. Is the origonal way you set it up bad because it was just a string representation of the weapon vs enum? Is enum better because of ease of swtiching AND last, it looked like you srt a property in your weapon class, acalled weapon type to an enum but how could these change? Sbould it be a get/set?
ОтветитьThis is exactly what I was looking for!
Awesome!!!
How can you iterate through the values of an enum?
ОтветитьHow do I go into another state while in a different state, so not your base movement.. i.e. Going from sprint to dodge without letting off sprint
Ответитьif you want to select enum
public enum YourEnum
{
Dog=1,
Cat=2
}
public YourEnum YourEnumToChange;
public void YourMethod(int yourInt)
{
YourEnum selectEnum = (YourEnum)yourInt;
YourEnumToChange = selectEnum;
}
public void TestChageEnum()
{
YourMethod(2); // YourEnumToChange become Cat.
}
Quicker Tip (and another reason to use enums instead of strings (not that more convincing was needed)): Learn the magic of double-tapping Tab in Visual Studio
1: Make your enum, and currentState value
2: In your chosen code block, type "switch" and double-tap Tab
3: Fill in the name of your currentState variable and double-tap Tab again
4: Watch in amazement as VS automatically fills out your switch statement with all the cases
Double-tapping Tab also works for other things like loops and 'if' statements. For loops, you can also (single)Tab through the arguments instead of manually highlighting them and typing over them. Unchanged arguments should be highlighted in orange. Once the arguments are filled out, just hit Enter, and your in the block.
hii code monkey .. i just want to know the name of this part after the instance of the class
new weapon() { weaponType = "pistol" };
Hi! I was wondering how you would have to reference the different States. Thanks
ОтветитьHi, thank you for this video. really helped me get an understanding of how enums work. but what i'm struggling with is accessing an enum for another code. Could you possibly help me. i created this on the enum script 'case GhostStates.FRIGHTEND:' and i want to activate that 'State' in another code.
the other code has: 'public Petrol.GhostStates Gstate;' on top with ontriggerenter, once the player collects the item:
void OnTriggerEnter(Collider col)
{
if (col.tag == "Player")
{
Gstate = Petrol.GhostStates.FRIGHTEND;
}
}
im not getting any errors but it just doesn't work. Thank you
A neat little trick for visual studio, is that if you have your enum setup with all the options, you can just write "switch(EnumName)" and pres tap, and the editor will automatically write a case for every option
ОтветитьWHAT A LEGEND! ......short and on point , why not all the tutorials are like this
ОтветитьWoah this guy is actually replying to all the problems, i am doing a course for 99$ i didn't have to pay but the instructor doesnt even reply. I subbed.
ОтветитьThe typing speed at some moments though... Galaxy Brain Time!
ОтветитьQuick, short, precise. Love it
ОтветитьThank you, very simple and easy to understand
ОтветитьThanks for the tip! Question on the state handling, what if my code uses both update and fixed update to handle input and physics, how are you handling the switch statement if specific code needs to run on a state and on a specific update hook?
ОтветитьYou should make a Discord server! :D
Ответитьcould you do a video about the 64bit requirements for google playstore because i thought of exporting as an apk and opening it up with android sdk and then exporting it again.
Ответитьhey i just started with making my first game and im getting a problem its a error CS1513 expected and i dont know what to do about it does somebody know what i need to do thx
Ответитьfirst time saw a programmer with white colored skin
ОтветитьGreat Video! Can you do a video about ping pong ball physics like reflects the wall and contienue to move? I have it as challenge I did the PlayerMovement and now I need the Ball physics reflection but I habe no idea how to code it
ОтветитьHey can u guide me which gpu i should buy with
Ryzen 5. 1600
With 16 gb ram
For unreal engine
(plz reply if u can)
(i am confuse b/w rx 580
And rtx 2060)
Thanks, how about doing a second video about enum Flags / bitmasks? Not many who start coding with Unity know how to use them.
ОтветитьWhat’s the advantage of using an enum over a string array?
ОтветитьMake a video on tower defence game
ОтветитьEnums ftw!
ОтветитьI used to use integers for state management, but it sucked to forget which number meant what. This is really helpful!
ОтветитьCan I use this for leveling up system in my character? Right now I'm trying to figure out how to use leveling up system on unity. Like for example you need to have 200 experience for level up to 2
ОтветитьI learned this trick the hard way...thanks
ОтветитьA video about Events pls
Ответитьai tutorial??
Ответитьi find enums useful. in some cases i get confused on how to implement them. such as can i use a button to change a enum. if i can i haven't figured it out yet.
ОтветитьThanks :D
ОтветитьHii bro love your vids (even those which I don't understand quite a lot)
ОтветитьFinally
Ответить1st
Ответить