Switch statement and Enums - C# Basics for Unity Beginners: #9

Поділитися
Вставка
  • Опубліковано 29 чер 2024
  • In part 9 we will look at what is Switch statement and how it helps us to create branching logic. Next we will explore Enums and how they make our code more readable.
    C# Basics for unity series:
    • Unity C# Programming B...
    Welcome to this C# Fundamentals for Unity Beginners series of 10 videos. We will first explore what are the basics of C# syntax and next we will create a small Vampire Survivors like game together so that you can see Why and How different C# concepts are used to create games in Unity.
    -----------------
    Starter Project:
    / c-essentials-for-99701780
    Learn more about C# & Game Dev in Unity in my video courses at:
    courses.sunnyvalleystudio.com/
    ---------------
    Join the discord:
    / discord
    You can support me through Patreon:
    / sunnyvalleystudio
    Assets used:
    kenney.nl/assets/tiny-dungeon
    ---------------
    00:00 Switch Statement
    01:43 Switch statement for spawn point selection
    01:52 Coding an if statement
    12:09 Local scope using { .. }
    15:54 What are Enums and how to use them
    #unity3d #csharp #coding #gamdev
  • Розваги

КОМЕНТАРІ • 2

  • @dertobbe1176
    @dertobbe1176 3 місяці тому +1

    I dont get it. I mean it's basically another type of else If, isnt it?

    • @SunnyValleyStudio
      @SunnyValleyStudio  3 місяці тому

      Yes both of those are "Selection statements". In general if you have multiple conditions for the same input value you would use switch statement. It is much clearer that all the cases are about comparing this one value. Also check out this video to see why I would suggest using switch statement ua-cam.com/users/shortscQOQGvrjOac
      If statement is better to check one condition and branch the logic "If player is dead stop enemy movement else move". You can "else if" instruction to do the same using if statement.