Teaching Newbies since 2014

kauress

  • Home
  • Javascript ❤
    • JavaScript
    • Node.js
  • WebDev Tuts
  • screencasts
  • Resources
  • VR & AR
  • Contact
  • Github
  • Twitter
  • YouTube
  • RSS
  • C++
You are here: Home / Unity3D / Introduction to C# in Unity #11: 🥑 If conditional statement

February 16, 2021 by: Kauress

Introduction to C# in Unity #11: 🥑 If conditional statement


🥑We use conditional statements all the time in real life. For example, suppose you go to your favorite restaurant and you ask for what you always eat there – Fish & Chips. The server lets you know that you can’t order that since they’ve run out of Fish and to please choose something else. So you order your second best choice – Pizza.
🥑Another example:
If you do you’ve done your homework only then can you play game.
Else you need to finish your homework first.
🥑In your code when you're making games you can control the way your program behaves/executes with conditional statements. If conditional statements can control the output of your program based on whether something is True or False.
🥑 Often used with comparison and equality operators
🥑There are 3 conditional statements that you can use: 
1. If
2. Else
3. Else if 
 Use if to specify a block of code to be executed, if a specified condition is true 

if (condition) {
//code to execute if the condition is true 
}
Introduction to C# in Unity3D #10: While Loops ➿
Introduction to C# in Unity #12: 🥑 else block

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2021 ·Kauress