Getting the transcript
Reading the captions from YouTube. A video nobody has opened here before takes 10 to 30 seconds; this page fills in on its own.
Getting the transcript
Reading the captions from YouTube. A video nobody has opened here before takes 10 to 30 seconds; this page fills in on its own.
![Learn C# Beginner FREE Tutorial Course! [2026]: video thumbnail](https://i.ytimg.com/vi/pReR6Z9rK-o/sddefault.jpg)
Code Monkey · @CodeMonkeyUnity
Where viewers went back to watch this video again, from YouTube's public Most replayed graph, lined up with what was said at that moment.
Most replayed moment #1
21:192.5x the video's typical replay level
that we want the console application so let's use this one okay now let's give it a name you can name it whatever you want here I'm going to go with the basic hello world then go ahead pick a location to spawn your project and leave the solution the same name as default okay so like this let's go on next then over
Said at 21:12
Most replayed moment #2
26:032.4x the video's typical replay level
various Unity versions in case you see something that looks like this this is actually the older version of The Hub so like it says here there's a button to update so let's do that and yep here we are in the updated Unity Hub it asks you to sign in so go ahead and do that if you don't have an account you can create
Said at 25:56
Most replayed moment #3
3:11:512.4x the video's typical replay level
Said at 0:00
The graph counts replays. It does not show where viewers stopped watching.
Words
21,346
Runtime
3:56:50
Speaking pace
90wpm
Reading time
89min
90 words per minute, below the 160 25th percentile of 349 measured videos. That distribution comes from the 349-video hook study.
Opening (first 30 seconds)
hello and welcome I'm your codm welcome to the free beginner section of my C Mastery course by going through this course you'll be able to make games websit apps Robotics and literally anything C is an extremely versatile language starting from the absolute Basics
45 words, the words spoken in the first 30 seconds at 90 words per minute.
Free, no signup. See how the first 30 seconds hold attention, with rewrites.
Sentence shape
| Measure | This transcript |
|---|---|
| Sentences | 13 |
| Average words per sentence | 1642.0 |
| Longest sentence | 5,425 words |
| Questions asked | 0 |
| Sentences containing a number | 8 |
Most used terms
Filler phrases
229 in total: like 108 · actually 47 · basically 45 · kind of 24 · literally 2 · sort of 2 · you know 1.
A literal whole-word count of the same phrase list the Prepublish browser extension uses, so a phrase inside another word is not counted and a phrase used in its ordinary sense still is. It is a count and not a judgement.
What this transcript is
Every word below is the caption track YouTube publishes for this video, pulled from the video itself and reproduced unchanged. It is not Prepublish's writing, not a summary, and not a re-transcription: it is the video's own published captions. English captions, generated automatically by YouTube, in the video’s original language. Source: the video on YouTube. A channel that would rather this page did not exist can ask for its removal through the contact page, and it is removed.
hello and welcome I'm your codm welcome to the free beginner section of my C Mastery course by going through this course you'll be able to make games websit apps Robotics and literally anything C is an extremely versatile language starting from the absolute Basics like how code executes line by line and what is a variable then covering the intermediate topics like what are interfaces generics and events and how you can use them to build some really awesome things you will also learn the theory behind how to choose good naming rules clean code guidelines and learn about design patterns and finally the advanced section which will be coming in a feuture free update we'll cover lots of very Advanced topics now this free YouTube video this one contains all the video lectures from the beginner section in the previous video I spoke about my goals to make the video lectures free over here on YouTube if the premium version course sells 100 copies then one month after this video I will publish intermediate section for free here on YouTube and same thing for the advance section one month after that and yep since the last video there's already been 100 people who picked up the premium version so one month from now stay tuned for the intermediate section or if you're watching this in the future then check the pin comment down below the premium version of the course has the video lectures just like this video plus all of the intermediate lectures and the advanced section coming soon as well as all of these really nice bonuses So speaking of that here are the bonuses for the premium version I came up with some that I think are really awesome and definitely worth it if you can't afford them well at the same time not putting any knowledge behind the pay wall so even people who can't afford it they can still learn from the free video lectures they really just need to do a little bit of extra work themselves the premium version is really just selling convenience making it really easy for you to truly gain the knowledge the the premium version comes with a companion project this is a Unity project that contains a bunch of extra content basically the video lectures while being preas of themselves there are still really only half the course the other half of it is inside of this project it has a bunch of custom editor Windows to guide you through each lecture and each lecture has a section on frequently asked questions these are common questions that have some really detailed answers that provide even more details on what is covered in the lecture then there are some quizzes these are multiple choice questions again own with very detailed answers it's really not just correct or incorrect if you pay close attention to each lecture you should be able to get most of these right but whether you do or don't by reading the extra explanation that will help you truly learn that topic then the interactive exercises I'm really happy with this feature I think this will really help you learn learning by doing is always much better and these exercises encourage you to put what you learned into practice instead of just blindly watching the video lectures I designed a ton of handcraft exercises for all the lectures to help you put into practice and truly learn the contents of each lecture there are all kinds of exercises some are about spotting and fixing errors others are about asking you to Define some function or class or Implement some kind of logic there are some where you just write code and somewhere you write code and then play the code in unity in order to complete the exercise then each exercise also contains a hint just in case you get stuck or a solution in case you get really stuck as well as a video walkthrough of me going through that exercise and completing it while explaining everything in detail so if you're the kind of person who gets stuck in tutorial hell then I truly believe that this will really help you escape it in order to learn you need to actually do things and this exercise in encourage you to do that they encourage you to do it as opposed to just blindly watching the video lectures then the companion project also has a companion window basically this window is also listening to a bunch of errors and if it finds one it will help guide you in the right direction I manually wrote a ton of text for when text lots of errors all of them based on common errors that I see people ask about in comments in my own videos so this should help prevent you from getting stuck in your Learning Journey and allow you to get helped instantly then the course also has an AI to help you answer questions this one was trained on the contents of the course and my own knowledge so it should be very accurate and helpful but more than that it's simply the fact that it is extremely fast you post a question in the course comments and within a few minutes the AI will respond with probably a very good answer although of course I myself will also still be answering all the questions manually the goal with this AI is really speed so you get a response almost instantly and then within the next few hours I will manually answer myself then a simple bonus is how the premium version has the course split into lectures as opposed to Here on YouTube where it won't be one giant video it has to be that way due to how the YouTube algorithm works works this is a small thing but it can be helpful especially if you take your time to slowly go through the course just like you should do remember that the only goal is really that you actually learning yourself it does not matter how quickly you go through it so separate lectures help with that so that you can pause and actually try out your knowledge before going further and you don't have to memorize specific time stamps and over here on YouTube the videos have the normal YouTube ads as usual whereas the premium version has no ads so there's nothing to interrupt you while you're learning another really nice bonus of the premium version is something that I'm going to try out for the first time which is a live study group basically once or twice per week I will go live and post a link to the live stream so people can join in there I will watch the lectures alongs side of you then we're all going to read the frequently asked questions together do all the quizzes and go through all the exercises naturally I won't be reading the chat so I won't be able to answer any specific questions you have I've really never done anything like this so I'm really curious to hear what you all think some people like to learn more as part of a group so hopefully this should be quite fun the first live study group is happening next Saturday March 9th and if you can't live then as always they will be recorded so you can watch the recordings later and final bonus is really just by knowing that by buying the premium version you won't be helping hit the goal to make the free video version available for everyone so you will be helping to make knowledge available to anyone who wants to learn so these are the nice bonuses that I came up with that I think are really nice and really awesome while not taking away anything or putting any knowledge behind the pay wall if you can afford then I highly recommend the premium version these bonuses will help you truly learn and learn much much faster than the 10 years that it took me but if you can't afford it that's okay like I said there's no hidden knowledge hidden behind the paywall you really just need to put more effort in yourself in order to actually apply knowledge that you gain and if you want you can go ahead and pick up the premium version right now there's a link description I added a nice launch discount so you can get it before the first live study group next Saturday so whether you get the premium version or watch your free lectures I really hope you'll learn a lot also just in case you're new to my channel so a bit about me and my credentials or why you shouldn't listen to what I have to teach for me I've been programming for over 25 years and specifically using C for over 10 years I'm a professional indie game developer with several successful games PO on seam covering a wide range of genres my games are usually focused on complex systems since I am primarily a programmer it's what I really love to do and what I love to teach also a couple of years ago I started over here this YouTube channel making free video tutorials to basically share my knowledge to help you learn how to make your own games there's already over 800 free videos over here on this channel if you want to continue learning Beyond this course also let me make one very important note for beginners which is simply take your time remember this is your Learning Journey no one else's the only thing that matters is that you're learning it does not matter how long it takes you so it does not matter if someone learns all of this much faster than you you are really not in competition with anyone but yourself also you are not expected to go through this course in one day one week or even one month basally all the content out of this course this contains knowledge that took me 10 years to learn so really just take it slow take your time and really just focus on learning and one final request if you find this video helpful if so go ahead and hit the like button and subscribe to the channel it's a tiny thing but it really does help all right so let's get to the first lecture starting from the very beginning first we're going to learn what is C and what have the many use cases for it then on the getting start lecture we're going to install Visual Studio which is where we're going to run our code then we're also going to install unity and learn the unity Basics this is an optional step but it's important since the interactive exercise and quizzes those exist in a Unity project after that we're going to load up that project to see how the interactive exercise work and then is a really useful lecture covering some very common errors you should refer back to this one whenever you encounter some issues after that one we can finally start writing some code beginning with the absolute Basics learning how the code is written how it executes what is a code block and how code is case sensitive then we're going to learn about variables these are containers for data the data needs to have a specific type so then we're going to learn about the various built-in data types things like int B string and so on next we're going to learn about if statements this is a core pillar of any programming these are conditions which affect how your code will execute after that we'll learn a different way of handling condition using a switch statement next we'll learn about another core pillar functions this is how we can place logic in separate functions and call them when needed after learning about functions which involves different code blocks then we are going to learn about variable scope which is basically from where that variable can be accessed next we'll learn about comments the Syntax for this one is actually really simple but it does bring up a lot of interesting questions regarding writing good clean code then we're going to learn how to store multiple pieces of data in one container using arrays and lists afterwards we're going to learn all about loops this is how we can run certain logic multiple times like for example looping through all members of a list then another crucial pillar of object-oriented programming we're going to learn the basics of classes how to define one and construct it next we will be ready to learn about static what is the difference between making something static and non-static then learn about access modifiers this is another one that is super simple in terms of syntax and extremely important in terms of learning to write good clean code after that comes one of the most important lectures in this whole entire course it's a lecture on naming rules and how you should be very careful and and very deliberate about the names that you use in your code and after that is yet another extremely important lecture this one covering the theory behind why you should write good clean code as well as some nice simple guidelines that you should follow with all that done we will have learned the absolute Basics so we will be ready to inspect a nice beginner project that involves everything we learned in this section all of that makes up the beginner section and afterwards comes the intermediate section we're going to take things up one level and learn some more complex stuff beginning with something very important that I debated whether I should put in the beginner section it's going to be Visual Studio shortcuts I end up putting it here because for beginners technically it's more important to learn how to write the code and it's not as important to be extremely efficient with how fast you use your ID but for intermediates this is a must have so we're going to learn about a ton of shortcuts to help you write code and navigate your environment much better then comes one of the most important lectures in this whole intermediate section it's all about refactoring this is the process of rewriting your code to make sure it is as readable and understandable as possible as an inter it you absolutely need to know that this is a natural part of the code writing process and something you should not skip next is a lecture on enom pretty simple and very useful it's how you can define a specific list of values that you can use in many ways after that we'll learn about properties which are kind of like a mix between variables and functions then we're going to learn about multi-dimensional arrays meaning arrays that can hold multiple dimensions of data after that we're going to learn about nest and Loops which is especially important in order to cycle through multi-dimensional arrays next we're going to learn another method for doing some looping logic we're going to learn about recursion this is something that for people with a math background it might actually be similar to understand than R Loops then we're going to learn about an extremely useful data type the dictionary this is a key value pair that has tons of really awesome use cases after that we're going to learn about some more collections like q and Sack then we're going to learn about the prams keyword and what exactly does it do in a function next we'll learn about optional parameters how to define them and how to call them from a function then another crucial lecture for intermediates this one is on learning the differences between value and reference types this is extremely important if you don't know this difference then you will go crazy at some point in the future wondering why something isn't changing and it's usually going to be because you don't know you're working with a copy and not a reference related to that is the lecture on structs these are similar to classes but importantly they are a value type next we're going to learn some more intermediate use cases for classes we're going to learn about inheritance polymorphism and a bunch more then learn about interfaces this is one of my favorite features of C it allows you to write some really nice modular code related to that we're going to see various ways of testing for types and converting two and from various types also related is the lecture on switch pattern matching this is a really simple way to do a switch not just on value but also on type then we're going to learn all about delegates lambdas and Anonymous functions this is how we can store a function itself inside a field next we're going to learn the differences between lambdas and local functions after that we'll learn about events which is how we can have one class be notified when something happens then the next lecture that one is going to be all about generics this is another super powerful C feature that makes your code work with multiple types next is a simple lecture on conents and read only what they are and what are the differences between those two after that is in lecture on exceptions and how to handle them with a try catch then in lecture on implementing I enumerable so we can add support for something like a 4 in for some custom types next we're going to learn about namespaces what they are and how to make your own then a really important lecture on one of the most important design patterns the single tent pattern and after that is a general overview of a bunch more design patterns and finally after doing all of that we're going to check out the intermediate project that uses all of this to make something really interesting so that makes up the intermediate section and then comes the advanced section for this one like I said in the beginning I'm still actively working on it so this will be coming later as a free update here are the topics that I'm planning to cover all right so that's everything we're going to learn in this complete C course like I've said many times you are not expected to go through all of this in just one day or one week or even one month it took me 10 years to learn all of this so always remember that and take your time and really just focus on actually learning this is your Learning Journey so that's really all that matters take it slow really pay attention do all the content in the companion project and I guarantee that if you do that then by the end you will have gained a massive amount of knowledge hello and welcome I'm your Cod monkey in this lecture we're going to learn what exactly is C and what it's used for okay so C is a program language it was created by Microsoft in the year 2000 it is an objectoriented General multi-purpose language with tons of use cases for me specifically the main way that I use it is for game development with unity but you can also use it to make websites with asp.net or Blazer you can use it to make Native mobile apps with zamarin you can do tons of stuff in the cloud it's especially easy to use with Azure which is Microsoft's cloud service you can develop on Internet of Things devices or you can use it to make some simple desktop apps to help you in your daily life you can make console programs or visual desktop applications so it has tons of use cases it is multiplatform meaning you write C and you can run on Windows Mac Linux and other platforms the language is constantly evolving despite being 24 years old it is still actively being developed with new versions coming out on a regular basis it is also one of the most popular and independ languages so it's a great one to learn personally I also believe that it's a great first language to learn I especially like how it's typ save meaning it has very specific types and if you write some code incorrectly you will get a compounder war instead of having an error suddenly show up while the code is running and if you're not a complete beginner if you already know Java or C++ then chances are you won pick up pretty easily since it is relatively similar to those languages so yeah personally I'm a huge fan of C I've been using it pretty much every single day since I started game development with unity over 10 years ago I've made tons of games with it and I've also used it to make some personal desktop apps and I also use it when I explore the cloud so it is a great very valuable language to learn and if you pay close attention to this course then by the end you will have gained a massively valuable skill hello and welcome I'm your K monkey in this lecture we're going to go over how you can get help when you need to and how to get the most out of this course okay so learning programming can be a little bit tricky at first especially if you are a complete beginner right away let me say that is perfectly normal if you are a beginner and some things seem quite confusing that is perfectly okay that's all part of the regular learning process so there's really no point in getting frustrated just take your time and really just focus on trying to learn in order to help you learn this course has a bunch of things for every lecture the unity project contains a bunch of helpful common frequently asked questions I highly encourage you to always read through those as you go through each lecture and whenever you have any question then I also highly encourage you to go answer all the quizzes for every lecture and do all of the interactive exercises you will learn so much more if you're being active in your learning as opposed to just passively watching a video so definitely make sure you do those after watching every lecture pause go to the N project and do all of those also on that Unity project if you write some code that has some error the companion can provide some extra clarification on what exactly that error means so if you're having some issues and you're writing code in the C console try writing that same code inside Unity to see what the companion says then there is a really important lecture covering a bunch of common errors if you have errors in your code chances are the error has an explainer in this lecture also when you have some issues the first step is to actually identify what exactly is the issue and for that the best way to find it is to add tons of logs in your code at various places to see exactly what the code is doing line by line there are many cases when beginners think the code is doing something but in reality it's doing something completely different adding logs is a super easy way to help you visualize exactly what the code is doing and of course you can simply post questions in the comments of that lecture one bonus this course is the automatic bot response you can ask something and within two to three minutes the bot will reply I train the bot on the contents of the course and my own knowledge so the answer should be pretty good the main benefit of the bot is the near instant reply so you don't have to wait for me to reply and you can continue learning quickly but also after the bot replies within the next 24 hours I will manually answer your question and confirm or provide some extra clarification on whatever the bot said then here's also a quick guide on how to ask a good question for example do not just say it's not working just saying this is really not helpful technically not working can mean a million different things for example do you have a compile error if so what exactly does it say specifically what line of code is throwing that error or if it's not some kind of compile error how exactly is it not working so did you expect one result but got another did the code seem ly not run are you getting some different results from what you see in the video in order for me to be able to help you I need as much information as possible there's really not much I can do to help if the only message I have is it's not working so when posting some question be very very specific about what exactly is the issue so I can do my best to help all right so that's see many ways you can get help throughout this course just keep in mind what I said in the beginning if you are a beginner It's Perfectly Normal that something seem quite tricky to understand that's all part of the regular learning process so don't get stressed about it all that matters is that you learn learn it really does not matter if it's easy or hard if it's fast or slow as long as you're learning then you're doing great remember that I've been programming for over 25 years so if you manage to get through this entire course and fully learn everything in it in just a few months then you're doing so much better than me so really just take your time use all these tools at your disposal to really learn and let's get started in the next lecture hello and welcome I'm your Cod monkey in this lecture we're going to install and set up visual studio which is where we're going to be writing our code okay so let's see where we're going to write our code you can use whatever ID you want ID stands for integrated development environment some common examples for C are visual studio code jet brains Rider or normal Visual Studio you can follow this course using whatever IDE you want but if you're a beginner then it's probably best to use the exact same as me here I will be using visual studio 22 the community version this one is free also an important distinction it is Visual Studio not Visual Studio code it's a bit confusing how the names are very similar but those are two completely different programs here I will be using the regular visual studio so like downloaded go to visual studio. microsoft.com then click on downloads and download the free community version then go ahead and open up the executable file after installing right away it opens up the visual studio installer this is the main program that manages all of your installed versions of visual studio and right away we can install Visual Studio Community alongside a bunch of modules like I mentioned in the previous lecture C can be used for a lot of stuff and visual studio you can also develop on other languages so here you can see tons and tons of modules the ones that we're going to need in this course are the net desktop development this will let us make console apps which is the main template that we're going to use to learn C so make sure to include that one and then since the interactive exercises since those are built in unity also make sure to include game development with unity okay so these are the two main ons that we need so let's go ahead and install this will't download all the modules and install them okay it's done and launches visual studio right away now it's asking for a sign in this can be useful to transfer your settings across devices so if you want go ahead and sign in or just click on skip for now then for the theme again you can choose whatever you want personally I'm going to go with the light theme which is what I like but you can use whatever you prefer and right away let me answer the question that I inevitably get every time I say that I prefer the light theme when so many people seem to prefer Dark theme for me my eyes simply get really messed up in dark mode if I try focusing on white letters on a black background I get a massive headache really quickly so personally for me I use light mode but this is really just a visual change so choose whatever you prefer okay with that let's start using visual studio and Y right away we can see the project list although it's empty right now we can open a project or create a brand new one so let's do that then here we can choose the templates let's go ahead and make a simple console app which is the most basic thing possible so you can search for console up here and now yep it is this one right here the one that has the C icon in the corner it is not this one with VB that's for Visual Basic and also not this one for F this is for f and it is also not this one that says C but also says NET Framework it's a bit confusing but net and Net Framework those are two completely different things right now in here we want net and not NET Framework so yep it's this template also if you don't see it then go back into the visual studio installer click on modify and install some modules and then make sure net development is checked okay so this is the template that we want the console application so let's use this one okay now let's give it a name you can name it whatever you want here I'm going to go with the basic hello world then go ahead pick a location to spawn your project and leave the solution the same name as default okay so like this let's go on next then over here we can choose the framework so for this let's go with net 8 and now there's a pretty important option here which is whether or not use top level statements basically if you leave this unticked so like this then the project won't be created and look pretty much empty whereas if you take this then the project will be created and look like this with a namespace program and a main function the option for this difference this was added relatively recently so if you watch all their C tutorials they might show this template but for complete beginners it's completely empty option it's actually easier to follow so we're going to use this one later on after we'll learn the absolute Basics we will make another project with the more complex template but really the main takeaway that I want you to learn from here is really just code is code meaning that for everything we're going to learn in the absolute basics part using this simpar template all of that can also be done in this more complex template the difference is simply in how in the basic template you just write code here but in the more complex template you need to write that same code inside the main function if you write code in a different place you can get some strange errors so that is why for beginners the simpler template is much easier so over here to keep things simple let's first use that basic template so make sure to leave this one unticked so example down like this and let's create all right yep so here is our empty template and by default it already has a standard hell World print you don't need to understand this line of code just yet I will explain all of this in detail soon right now we can just run this test so on the top right on middle you can see this nice little play button or alternatively the default shortcut is F5 so go ahead and press either one of those and up here is the window our program ran it did indeed say hello world and everything finished all right awesome okay so we can already start writing some C code and run it now let's change some things in visual Studio there's a really nice extension that I really like which adds a bit more color to the code which I find that it makes it much easier to read and write so up here on top let's go into extensions and then manage extensions then go ahead and find Vora you can go to the online Tab and search for it now I believe that this one is actually only available on Windows so if you're on Mac you might not be able to find it maybe there is an alternative but I'm not sure either way this is just an optional extension just to add some visual so technically you don't absolutely need it but if you are on Windows and I highly encourage you to install it let's go ahead close visual Studio to let it install okay great so done let's open up the same project again all right so now for some more settings you can go into tools and options and over here let's scroll down to find vs and here are the settings now for the most part I believe the ones that I have here are the defaults you can pause the video and compare my settings with your own I believe I really only changed some colors over here on the rainbow braces right away if we look at our default hello world code it should already have some colors that make it a bit easier to read again this is not a requirement you don't need this extension but I do find it quite useful I find it helps to make the code more readable than having almost everything is gray next for some text formatting rules let's go up here into tools and then go into options then over here let's scroll down and find the text editor and again pause the video if you want I think over here I think I have everything as a default then let's expand upon this one and look specifically at the C options and over here again pretty much the same default I think the only thing different is over here I disabled the automatic brace completion just because personally I don't like it and let's expand upon it see a few more things so these scrome bars then over here the tabs pretty normal they not Advance again I think all of this is pretty much a default but intellisense right like this and then inside the code style in general I think over here I didn't touch any of this so I think the only thing I touched was over here on formatting and the main thing that I changed was over here on the new lines basically the default is to have all of the currently braces all of them on new line and over here I switch this ones in order to make them spawn on the same line which personally I prefer but again this is very much personal preference the code really doesn't care whether the braces are in the same line or new line so you can use whatever form you prefer personally I prefer it like this I've been using this code sound for 25 years now so this what I won't be using in the course but it's just a visual thing so if you really prefer it on new line then go ahead and place it on new line okay so after all that Visual Studio is set up and ready to go now let's continue on to the next lecture we're going to install unity and learn the absolute Basics hello and welcome I'm your Cod monkey in this lecture we're going to learn the basics of unity now like I said this part is technically optional if you're just looking to learn C then technically you don't need to learn Unity but since I won't be using Unity to build the inter active exercises and also using it to Showcase some example code with some fun visuals to help you learn better because of that even if you don't specifically want to learn Unity still make sure to watch this lecture just so you're not confused when any Unity code shows up first we need to get Unity Hub now since we selected unity game development when we installed Visual Studio it already automatically installed Unity Hub in your case if you accidentally did not take that box you can just manually go to unity.com and download it then open up Unity Hub this is the program that manages all of the various Unity versions in case you see something that looks like this this is actually the older version of The Hub so like it says here there's a button to update so let's do that and yep here we are in the updated Unity Hub it asks you to sign in so go ahead and do that if you don't have an account you can create one it's free Unity itself has a free personal version so you don't have to pay anything go ahead create an account and log in and right away it selects a version to install here you can install this version right away but we're actually going to install a specific version that might or might not be the same as the pre-selected version depending on when you're watching this so over here either way you can either install or skip this then here we have un Hub open on the left side we have some buttons we can manage our account we can install various un versions or check out the projects so over here on the projects tab we can add a project but before doing that let's go ahead and download the interactive exercises project go on to the course website on this lecture then scroll down and find the downloadable project files yep it's this one so go ahead and download that it's a simple zip file just open it and extract it somewhere and now back here in unity Hub let's go in the project Tab and then up here let's add a project select the one we just downloaded and let's open okay yep so here it is and over here it says the version that this project was built with if you don't have this version you can click this button to download it and yep it will download the correct Unity version now technically I should say you can load the project with a later Unity version doesn't specifically have to be this one but in order to avoid any confusion with menus being in different places in order to avoid any of that I highly encourage you to use the exact same version so there it is everything is installed everything is ready so now we can click to open up this project and yep here is the project open now let's just do a little bit more setup for example let's go up top over here let's go into edit and then let's open up the preferences then over here on this window on the left side let's scroll down into external tools and over here for the external script editor make sure you select your Visual Studio installation or if you prefer you can obviously use a different ID but if you're following everything along with this course make sure you select Visual Studio okay then for the extra options you can leave everything like this and here's a screenshot of my general options I believe all of this is the default so now we can close this window and now if we have correctly set the external editor if we go up here into assets and then click on open C project Yep this one should open your Visual Studio okay great so far so good now just one thing you should already see the code kind of like this meaning with a bunch of colors so for example if I place the mouse over here on top of mono Behavior it should correctly identify this is a class inside Unity engine this is a Unity specific class if you don't see it if you Mouse over this and doesn't recognize this type or if you see this as written in complely Gray if so then perhaps something went wrong during installation so you might need to manually install the visual studio tools for Unity you can just Google Visual Studio tools for Unity you'll be able to find this page and you can can download it but if you follow everything then everything should be working correctly okay great okay so here we have the default Unity layout now first things first let's just familiarize ourselves with the various Unity Windows and create our custom layout you can see there's a lot of tabs everywhere like for example the scene tab the game Tab and so on you can click and drag and move these tabs anywhere you can make them into separate places or you can dock them into various kinds of places so you can basically set up the editor in any way you want but it won't be easier to follow this course if you're following the same layout as me so let's see the layout that I normally use first is over here the inspector on the right side this way we always have a nice view of the select object and whatever scripts it has then for the Hier key personally I prefer that instead of here I click and drag and I put it right here next to this one I like having the Hier key over here on this lower left corner we're going to make sure our scene is always organized so we don't need the Hier key to take up tons of space then with the project files next to it and with the console tab on the next tab next over here in the center here we have the scene View and right next to it the game view this way we can easily view all of our objects the console project everything is nicely accessible so this is the basic layout that are normally use now for just a couple more options over here when the project files window is selected on these three dots on the top right corner on these personally I like to select the one column layout it showcases all the project files in a nice compact view then on the console next to it once again on the three dots over here we have some options for example over here on the log entry I like to set it to one this makes the console nice and compact which personally I prefer you can see a bunch more logs without taking up too much space then the time stamp are either enable or disabled doesn't really matter one very important thing are these three buttons over here these are the type of messages that are going to appear on the console so the left one this one is for regular messages we're going to use this quite a lot the second one is for warnings and finally for errors basically if you un toogle any of these then those types of messages will not show up over here on the console so if you ever come across an issue where nothing is showing up on the console make sure these three buttons are tick then over here on the left side for the clear we have some options so on this little arrow I like to set it to clear on play which means the console will be cleared every time we start playing our game then for the collapse this one basically collapses messages that are exactly the same into just one entry personally I do not like this I think this is very confusing I want to be able to see every single message as it comes out even if it's identical to a previous one I've also seen this lead to a lot of confusion for a lot of beginners they think their code is just firing one message when reality it's actually firing hundreds So to avoid any confusion leave collapse un toggled and then for the error pause this will automatically pause the game when some kind of error occurs so for this one you should definitely have this toggled if there is an error you want to know about it you want to know when it happens so you can actually fix it okay so that's it for the console and now on the game view up here and over here on the button that says free aspect let's select full HD 1920 x 1080 this is the standard 16x9 aspect ratio then on that same button you can also enable vsnc this can be helpful because some of these demos are really simple so if you disable it they might run at like a th000 frames per second which is going to put a ton of unneeded stress on your graphics card so just leave it as vsync and then just one thing if you see your game view is looking a little bit too pixelated make sure on this here on this lad you are not fully zoomed in if I fully zoom in I can see this becomes a little bit pixelated this basically just increasing the size of this window so on this this one on the scale make sure it's pushed all the way to the left okay so that's the game view setup then for the scene view for this one pretty much all default should work just fine just one thing to know some demos are in 2D so for that up here on the top right corner there's a button to swap between 2D or 3D this just changes the scene camera and then one important thing is on the top left corner over here there's these two buttons this impacts where the handles are actually going to show up usually you want to keep them just like this meaning this one on pivot and this one on local if you ever see your handles on some weird places always come back to this you almost always want it to be on pivot and local okay so here we have our basic layout it will be easier to follow the course if you're using the exact same layout as me so ideally you should be using this but again all the windows are customizable so if there's something you absolutely prefer differently then go ahead you can drag your windows and place them anywhere once you have layout your happy with you can go on the top right corner and over here where it says default you can click on it and we can basically save a layout so you can go ahead save it to something and then if you ever find any issues you can reload a previous layout so here we're back into default and if I click it yep now back into this one okay so now that the layout is all set up let's go through the basics of the UN editor so first just some basic controls over here with the scene view selected this where we can move around and view the entire game world you can hold the right Mouse button in order to look around then if you're holding the right Mouse button you can press W and in order to move around if you press on shift it increase the speed while holding the mouse button if you use the scroll wheel you can either increase or decrease the speed alternatively you can stop holding the right Mouse button and just press the middle bouse button in order to pan around or hold alt and left click in order to rotate around any kind of object and if you have have some kind of object over here on the hierarchy if you get lost like for example you're moving way far away and you have no idea where the object is you can just select it and then press the F key and it's automatically going to focus that object then here on the hierarchy window this shows all the game objects that exist in this scene a game object is really just a name for an object in unity so each one of these each one is a separate game object to create a game object we can simply click on the plus icon and over here we got a bunch of presets like for example inside the 3D object let's create the 3D cube let's press F in order to zoom in onto it yep there you go there's the basic Cube where an object is selected we can see the various gizmos the various handels that we can move our object so over here by clicking and dragging on these arrows we can move our object in any way then on the left side we see the various tools so the first one is just for panning around the second one is the move tool so we can use it to move our object third one is for rotating in any way then we've got the scale tool we can scale in any direction then the rec tool this one is mostly used for 2D and UI stuff but yeah pretty much also does some scaling and then the multitool which contains pretty much everything and another similar one for editing the bound volume although this one only affects the Coller and not the actual visual mesh so you should probably not be using this one okay so with the game object selected over here on the inspector we can see a bunch of stats for this game object Unity is really based on components so here we can see all the various components attached to this game object each component does all kinds of things for example this Cube game object first of all this one has a transform component all game objects are going to have this component this is basically what gives it a position rotation and scale then specifically for this game object this one as we can see it has a cube visual so that visual is composed of the cube mesh fil component this is what holds the actual mesh that is being rendered and the mesh render component this is what actually renders that mesh and finally by default this one also has a box and letter which is used in physics so in general the main thing to remember is that Unity is made up of scenes then each scene is made up of game objects and each game object is made up of components let's see an example from the interactive exercis they're all split into different scenes they're organized by folders so for example let's go inside the lecture teaching all about if conditions and let's open up this one for the distance the way we open the scene is just with double click and we can see this is a scene because that has a nice Unity logo so let's go in this case I don't want to save the sample scene and Y here's the scene and like I said most of the demos these are actually in 2D so we can click the 2D button in order to visualize it in 2D in order to play the game you simply click on the play button right up here on the middle and you up here the game view now is playing on whatever logic is in this particular scene this one is on the lecture talking about ifs and if I click to move and showcase how doing a simple if in order to test a distance so in this case for example let's inspect the player components so select the player game object on the Hier key and over here on the inspector we can see it as the player script so we can double click in order to open it and yep it opens up visual studio and opens up to the player script so here we can see a bunch of code again don't worry too much about what exactly this is saying what exactly this is doing this course W teach you everything about C so everything that we're seeing here we're going to learn about through the entirety of this course right now the only thing that I want you to learn with regards to Unity and C is that Unity scripts have some default functions they've got an awake function and an update function again I want to cover what exactly are functions in detail in a little bit so just know that the awake or also the start function those only run once whereas the update is going to run on every frame so if our Unity window is running on 60 frames per second then this code will execute 60 times per second then for some Unity specific things in order for script to be attach as a component it needs to extend this mono Behavior class in the unity scripts many times we are going to access the transform component so this refers to the transform component attached to whatever game object this script is attached to and finally debug.log this just a way that we can write any messages to the console so pretty much the same thing as the conso right line that we're going to see in a little bit okay so that's the absolute basics of unity like I said you can use C without Unity among using it to make the interactive exercises and to make the lectures a bit more visual which should help you learn better also by the way after you watch this whole course if you want to learn how to make games in unity then check out my entire course on making the game kitchen chaos it's a beginner course starting from the absolute basis of unity and game development and it takes you step by step until we have a nice complete fun game if you fully understand everything in this course you w be able to easily understand everything in that one okay so in this lecture we installed unity and learned the basics now we are ready to learn how the interactive exercises work which we're going to see in the next lecture hello and welcome I'm your KMI in this lecture we're going to learn how the companion project works okay so the companion project is something that I work really hard on to help you truly learn the contents in this course if you do what I say if you make an effort to go through everything all the content inside of this companion project if you do that then by the end you will have definitely Master C if you're following along you already downloaded in sound the project if not go ahead and download it from the link under this lecture so the companion project contains a ton of stuff first of all everything is over here on the project files all separated by lectures so all the demos that I Showcase in the videos you can come here and inspect them in order to see all the code that makes up those demos but also the main way to interact with this project is through a bunch of custom editor Windows the main one is the main window so it should be open already if you import the project if not you can go up here onto the Code Monkey menu and let's open up the main window and yep it is this window now the first thing this window actually has is an update Checker that runs automatically as I add more exercise or quiz or questions to the project as I do that I will update the project so when that happens you will see a nice popup where you can click which will take you to this very lecture where you can always find the latest project version then over here you've got some nice stats so basically it tracks your completion as you go through all the content in the course it will keep track of all of it the goal is for you to get to 100% completion by the end then we have a button that takes us to the lecture list so over here you can select what lecture you're on like for example let's say we are inspecting the variables lecture and now we can browse the three parts for each lecture there are frequently Asked question questions quizzes and exercises each of these has a separate Unity window by clicking on it it should open that window so for example here is the one for frequently asked questions this one shows some common questions and if you click through it you get a very detailed answer so these provide even more clarification on the topic covered in the lecture next we have the quizzes so these are multiple choice questions you get a question and various options again these are related to the contents of that specific lecture so if you fully understood everything you should be able to get all of these questions correctly but whether you get them right or wrong either way you get an answer with nice explanation with some extra clarification and then the exercise window these are exercises that rather than just answering questions you have to actually write code for example here's a basic one from the variables lecture it asks you to define a certain speed variable so here on the text you need to edit some script declare a variable of type int with the name speed and assign the value five to it right away we can click on start exercise this is basically going to load up all the files for that exercise now this one is pretty simple we just need to follow the instructions so in this case we just need to define a speed variable so we can open up the exercise.
Cs file it should open up automatically and over here we see some more instructions in the comments so now here all we have to do is just complete whatever the exercise is and if you get stuck in any exercise all of them they all have hints which should help point you in the right direction then if you get really really stuck you can also just view the solution so this will tell you exactly what you need to do in order to manually complete the exercise or alternative there's a button to apply a solution this one is basally going to overwrite the exercise files with the correct solution then once you complete the exercise you can see a nice completion message and something very important is the button here for the video walk through this one is exactly what it says it's basically me going through the exercise explaining how to complete it and what exactly the exercise is teaching then when you're done you can click the button to complete the exercise this will basically clean up all the exercise file so you can go back and go on to the next one also some exercise have a Unity scene like this one so so you need to complete the exercise you need to write the code and then you need to hit play over here inside of unity in order to test your code and see if you have actually successfully completed the exercise if so then again same thing just stop playing complete the exercise and go on to the next one also related to the exercise window is a separate companion window which you should also open it should be opened by default in this corner if not again go into code monkey and open up the companion window so you have this is a really nice companion window that listens to a bunch of compiler errors and gives you some guidance this one is separate from the exercises so this is constantly reading for errors whether there's an exercise active or not so this can be helpful even if you're trying to write some regular code if you're trying to test out how something in some lecture actually works this provides a bunch of useful guidance for tons and tons of compiler errors so you should keep this window open and visible at all times I've said many times that the way that you truly learn is by writing code not just by blindly watching the videos you need to actually do something you need to apply your knowledge in order to truly learn so I'm really happy with this companion project that I built especially these exercises they really encourage you to write code related to the concept of each lecture and in doing so you will actually sidify the knowledge you gained there are many exercises for every lecture this is something that took a ton of work to make so I really hope you make the effort to go through everything in this companion project to help you truly understand all the contents inside of this course so as you're going through the course first watch and listen to the entire video lecture make sure you're paying attention and real learning pause the video and Rewind if you need to then after watching that lecture go on to the companion to project then over here load up the lecture list and go on to whatever lecture you're currently on then read all of the frequently asked questions and the detailed answers then go through all the quizzes and try to answer them all correctly and then go through all the exercises and really put into practice what you learned in that lecture you can see there's a bunch of content already for all the lectures up until this point so take this time right now to pause the video and go through all of this to ensure you are fully understanding everything up until this point by the end of this course you should have all of your totals set up 100% completion if you do that then you will truly have learned C which will then allow you to build anything you can imagine all right so we're almost ready to start learning C but before we do let's go through a bunch of really common errors in the next lecture hello and welcome I'm your kmy in this lecture we're going to learn about a bunch of common errors that you might encounter so here's a list of the many common errors that we're going to cover in this lecture this lecture is really mainly meant to act as a sort of reference whenever you have an error come back to this one to get some guidance on what exactly it means and how you can fix it I add this lecture right here on the beginning of the course before we get into writing any code just so you are aware of these various errors but if you are a complete beginner then don't worry about fully understanding everything in this lecture right now for most lectures I highly encourage you to stick with it and rewatch a lecture if you don't fully understand the contents but for this one this one is special this one is really intended as a reference if you are a complete beginner then watch this lecture just so you are aware of the various possible errors that you might encounter but don't worry too much about understanding all the the individual details in the code that we're going to see everything mentioned here variables classes type scope and so on these are all things that I will cover in detail in future lectures so just remember that this lecture exists and refer back to it if you encounter any of these errors starting with the most common errors of all some variation of these three usually these mean some kind of symbol is missing or it's in the wrong place one of the most crucial things about any kind of programming is how code has to be written absolutely exact if you miss just one symbol then everything breaks this is really something that a lot of complete beginners have a lot of trouble with for example here this code has an error and thankfully this one is actually a very helpful error it is correctly telling us that a parenthesis is expected here we have an opening but we have no close you always need to match the same number of opening and closing parentheses so the solution here is pretty simple just close it yep then here is another similar error this one is saying there's an ending currently braces expected and again same thing different numbers so we've got one two three openings but only one two closings so we're missing one here and here is another really common error this one is because we have a missing semicolon the semicolon is what actually defines the end of an instruction without it the compiler doesn't know that this instruction has ended in C SHP new lines don't really matter so I can paste another line down here and hope these are still errors having one line of code on each line does not matter what matters is the semicolon so always need to add it to this one and to this one then on these same mistakes if you make something slightly different so instead of the ending one you get rid of the first one now there's a whole ton of errors in this case they're not quite as helpful so that is why you always got to keep in mind you have to write the code perfectly and here we have tons of Errors so this is quite messy the one that truly matters over here is this one it's at the main function must declare a body so the missing here is once again has to do with the currently braces we've got three closing but only two opening so we're missing an opening on this one and again same thing if for example we forget to add this one then again tons of Errors so again this one is really tricky to figure out what is going on the issue here is our missing opening parentheses so these are really the most common syntax errors if you see any of these pay very very close attention to how your code is written remember it has to be written perfectly so don't write some messy text write it properly with all the required parentheses all the currently braces and semicolons next really important common error is simply this one the type for namespace could not be found so here I am trying to Define a variable but as we can see we have this are in the code this is yet another way as to how code must be written perfectly it is not just the words that matter code is case sensitive this is something that I see a lot of beginners having trouble with they think for example this and this they think these two are the exact same thing but they are not in terms of English sure they sound the same they look similar but in terms of the code these are two completely separate things the code really doesn't understand meaning doesn't understand English it really just understands syntax so always always remember how code is case sensitive changing something from uppercase and lower case just doing that one tiny change all of that suddenly refers to something completely separate again this is something that I see a lot of beginners struggleing with so this is something I will repeat quite a lot throughout the beginner section of this course if you have some error like this one the type or Nam space could not be found first thing you should do is always double check the capitalization double check that you wrote actually perfect so in this case it is lowercase int and yep that works also since we're here one thing that is not an error but rather a warning sometimes you might see these green squigle lines these are warnings or suggestions for how you can improve your code in this case just says the variable is assigned but it's never used again that's because just just some testing code in general just know warnings are not errors so for example I can compile this code and works perfectly the warning is simply a message that tells you that you're probably doing something that you probably don't mean to now here's a similar error it says the name age does not exist in this context and again same thing capitalization problem age on lower case and age with upper case on the a these are two completely different symbols same thing over here which is saying tap namespace player cannot be found and again some beginners might see but it is the finest right here except no it isn't once again same problem over here player is on lowercase and that one is capitalized so over here it needs to be written exactly perfectly and yep now it works and up here also perfectly and yep now it works so as a beginner the first question you should always ask yourself is did I write the code correctly and specifically in terms of case sensitivity is everything written perfectly exactly as it should be or not that should be your very first question another common error is this one it says use of unassigned local variable this one is pretty self-explanatory basically you need to initialize a variable in order to use it so in this case we really just need to give it some value and Y the error is gone related to variables and data types a common error is some variation of this one cannot implicitly convert one type into another one like it says this has to do with trying to convert one type into another for which there is no implicit conversion this is a common problem over here defining something as a float and then assigning that float onto something that sores an INT inss can really only sore whole numbers so that is why this does not work floats or decimal points but ins cannot if you absolutely need to do this then one thing you can do is simply cast the value so over here put int so you cast like that there's no error anymore however if you do it then this will lose some data for example if over here for number I store 5.6 if I do this and then I C it the value stored over here in h this one is going to be just five if you force the conversion then basically anything after the decimal is going to be ignored or the same error can be due to the data type that you're trying to store the data type this one represents a 6 4bit int whereas the int this one is only 32bit int meaning that along can store everything inside an INT and more you can define an INT and then assign that int onto a long this does work there's no error on this line however there is an error on this line that is because an INT cannot hold all the values of a long so you cannot implicitly convert a long onto an end again if you really really want to do it you can simply cast it onto an end or alternatively trying to do this again same thing cannot convert a string onto an INT if you want to basically parse a string then you can do it like this x is the convert class and convert it onto an n32 related to data types is doing some math so a common error is doing something like this so basically you got 1id by 10 and you expect the result to be 0.1 but nope the result is actually zero that is because when doing math between two inss the result is going to be an INT and in an INT we cannot sort the number 0.1 so again it ignores everything after the decimal point and returns just zero the solution here is to cast one of the numbers included in the calculation onto a float and if have another result is correct always keep in mind mind what data type you're using and make sure you're assigning the right data for the right type then another common mistake is when doing some conditions you might write an N like this so one condition and another one but this is not correct with just one m% this is actually a completely different operation this is a bitwise and and not a logical and so once again goes back to how you have to write the code perfectly for a logical and you need two erss or for a logical or it's also not just one pipe it's actually two also for equating values it is two equals if you use just one equals that actually is the assignment operator so that is something completely different if you want equality you need two equals then after we learn about functions a common is going to be this one the name AG does not exist in the current context now in this case the capitalization is correct these are both written perfectly exactly the problem here is that this one up here this one is a local variable and by being local it means that this variable only exists over here inside the main function and down here inside this other function down here does not exist at all this is a problem to do with variable scope and later on there is a detailed lecture on that specific topic also after we learn about functions and parameters one common error is this kind of error this is not a compile error it's just some Behavior difference here a beginner might think that if you define this then you add this and this one in turn is going to add two you might think that over here is going to add two onto that number but the answer is no when we run this line this one still says 35 so the value inside the age variable that one is still 35 this has to do with difference between working with something as a copy versus a reference there's a dedicated lecture on the topic of value types versus reference types in the intermediate section int is a value type which means that it is passed in as a copy so when we call this function what this one receives is a copy of the original data meaning it's just a copy it has absolutely no connection to the original variable so when we modify this one we're just modifying the copy and not the original value that is why over here when we call this the original value still stays exactly the same so always remember whether you're working with a copy or the original data then when we start using classes this is a common error it says an object references required for the non-static field method or property to be called in the class lecture and in the static lecture I talk a lot about the difference between the class definition and an instance of that class and that is exactly the problem here this function over here this one is not marked as static but we are trying to access it through the class name itself as if it were static like the a says we need an object reference meaning we need to create an object of this type in order to create an instance of that class so we can define a player equals a new player and now using this object this instance of that class now we can call it and yep everything works or alternatively we can keep the same thing we had previously and simply mark this one as static so always be very very careful are you intentionally trying to access something through the class itself or through some instance of that class another common error that we're going to run into once we start learning about classes is this one it says something is inaccessible due to its protection level this has to do with the access modifiers there's also a d lecture on this Topic near the end of the beginner section by default if you omit the access modifier then it's going to default to making it private and private means that only this class over here only this one can access this function so if you want to access it from elsewhere like for example from this function up here if so then we need to mark this as public and yep now it does work then when writing some more intermediate code you might encounter something that does something like this like require some encoding in order to save some bytes onto some text but if you just try using the encoding type if you do then it says like this once again the same thing the typew word namespace could not be found now this one is not a capitalization problem the class is indeed called encoding however this one exists inside the system. text namespace so before we can actually use it we need to be using that namespace so on top of f we need to add using system. text in this case and yep the errors go away and this now works alternatively you can place a mouse over the error then click on this little light bulb icon and this tells you a bunch of things like for example it needs using text and if there you go it does and it works all right so those are a bunch of common errors again like I said if you're a complete beginner and you didn't understand anything in this lecture that's perfectly fine all these Concepts variables functions classes and so on all this will be explained in detail in future lectures just keep in mind that this lecture exists if you ever get suck chances are you're going to encounter one of these errors if so come back here for an explanation on what might be going wrong and how you might fix it so remember this lecture and use it as a reference throughout the entire course now that we've covered this we are ready to begin learning the absolute basis of programming so let's learn that in the next lecture hello and welcome I'm your Cod monkey in this lecture we're going to learn the absolute basics of programming so how the computer executes code how code is C sensitive matching parentheses and a bunch more okay so in the getting stting lecture we built this default conso app project here we have a bunch of code again I will explain all this in detail in a little bit this one over here is a comment and here we've got something running a function order to print some text onto the console we can run this code so again we can go up here press F5 and yep it runs the console and right away it does say our message now the first thing to learn is how the code actually runs and that is how the code runs from top to bottom meaning if we have four instructions it is going to first run this line of code then it's going to run this line of code then this one and finally this one it is always going to execute one after the other always from top to bottom now later on when we'll learn more about functions we will see how the code execution jumps a little bit but in the end it's really all just sequentially running from one to the other from top to bottom so up here if I copy this line and I run this function twice and on the second time I say something else again code runs from top to bottom so it just going to first execute this one and print this line onto the console and then it's going to execute this one you know that it is exactly like that also one very important thing is in C the end of an instruction is denoted by a semicolon if we do not have it if I erase this then the code basically assumes that the instruction is not over another thing is how new lines don't really matter to the compiler so I can add a bunch of new lines and then the semicolon and now this is perfectly valid code all same thing when accessing a function so over here I can add a ton of new lines right after the dot I can add a ton of new lines now you can't add it in the middle of something like in the middle of this function name if I split it then it does cause an error but otherwise new lines generally do not matter in terms of running the code all that really matters is the semicolon that is what actually defines the end of an instruction a lot of beginners make the mistake of forgetting about that they usually forget about the semicolon and they get a whole bunch of Errors which by the way if you see a red squiggly line and you just put the mouse over it it won't tell you the error in this case the error is simple and our helper function actually helps us see what the error is so in here there's just an expected semicolon if we add it everything's fine so you find any strange issues always make sure to remember that you need a semicolon in order to end an instruction and also speaking of things that don't matter so new lines generally don't matter and another thing that does not matter is identation so right now I can ident this line just like this and it's going to run and I can have another one ented a bunch more so I can have code written like this and if I run it y everything still runs exactly the same if you've done some Python Programming then in that language initation does matter but over here in C it does not this is perfectly valid code although of course bad initation like this one can make the code hard to read so even though technically it does not matter for the compiler it definitely matters to you in order to make the code easy to read so always make sure you ident your code properly another extremely extremely important thing is how code is case sensitive meaning for example over here we've got an instruction a console. right line if I said right right line within lowercase L nope there is an error there is no such thing called right line within lowercase L there only exists one with an upper CASL so you need to always pay very very close attention to how you write your code this is one of the main things that I see a lot of beginners make their mistake they write code like this and they don't know why it's not working they assume that as long as the words are correct so for example if I write it like this they assume since this is technically the same thing as over here in terms of English they both say the same thing they assume that because that it should work but in reality no this does not work and the answer is always because they did not write the code exactly as it needs to be it needs to be 100% exact including capitalization so it cannot be in lowercase C it has to be an uppercase C only that actually matches the console and right line cannot be written like this the W needs to be uppercase and the L also needs to be uppercase so if you have issues in your code the first thing you should check is see if you are writing the capitalization correctly it is is not just the words that matter it's everything it's the capitalization it's the place where you put the dot the place where you open and close parentheses the semicolon all of that all of that matters so always make sure you write your code very carefully because every single detail matters and of course you can always rely on code autoc completion to help you write usually after writing a DOT you see the auto completion and if you start writing right line over here it shows you exactly as it should be you can just press enter and everything won't be written properly now the next important thing is knowing where to write the code now over here in the new template over here it's easy you can just just write code and all of this will execute without problems but now here on the previous Center template on this one note there's a bunch of currently braces these currently braces form what is known as a code block code is group between blocks for example everything inside of this code block everything here belongs to this namespace then everything inside this code block belongs to this class and everything inside this code block belongs to this function again don't worry what is a namespace class or function right now I will cover all of those in detail later on for now all I want you to learn is what is a code block which is everything inside a currently bracet and that impacts what kind of code you can write within each code blog so for example in this whole template in this one here we need to write the code inside the main function this is where the program actually starts executing like I said the code executes from top to bottom and as soon as we run this program it is going to start right here from inside the main function it starts running from this first line if we run just like this if there go it still works say exactly the same thing however if I take this code and I remove it from the function and let's say I paste it just over here so just inside the class code block if I do then obviously I get a whole bunch of error this because we are writing code inside a class block and inside a class block you cannot execute a normal instruction you can only Define Fields functions and so on now in this case the error isn't very helpful so really just remember where you are writing your code if you're writing a regular instruction that you want to execute then chances are you want to write it inside a function in this case chances are you want to write it inside the main function so always keep this in mind like I said it's very important how you actually write your code but it's also extremely important where you write it if you're writing code inside of this own template then make sure to not write the code out here here or directly inside namespace or directly inside the class if you're writing some kind of regular instruction make sure you write inside main although in the beginning portion of this course we're really just going to be writing our code in the simpler newer template just to avoid any confusion over here we have no currently braces so there's no issues like that we can just write all of our instructions over here sequentially and everything will execute once again top to bottom and finally very important is to always make sure you have matching opening and closing symbols that refers to for example code blocks every opening currently brace needs to have an ending one and same thing over here here for parenthesis every time there's one beginning there has to be a matching any one if I go ahead and I erase one of these like for example over here opening namespace we've got one then inside the class we've got two and inside the main we've got three and over here we have three closing ones but if I get rid of one of these if there you go now we have an error and this one is a nice up error so it tells us that one more is expected so always double check that you have the exact same number of both opening and closing braces and parentheses over here same thing if I raise one of these parentheses y that's also an error because we did not finish the parentheses that are calling the function so always make sure the same number of matching opening and closing if you put the cursor inside of it it should highlight the opening and the closing braces so if I put the cursor here it highlights both those if I put it here it highlights both those and so on and in general whenever you make some sort of error like let's say you forgot to write that you forgot to terminate the instruction you see the red squidling line so always remember you can place your mouse over it and gives you a bit more information sometimes the eror is super helpful like this one but sometimes might be a little bit more confusing so also remember you can refer back to the common errors lection sure to see some common issues or of course remember you can always post questions in the comments and I'll do my best to help okay so here we'll learn how code executes from top to bottom we'll learned how it's extremely important that code is case sensitive and you should always double check that you wrote the code exactly as it should be and we learned what is a code block and where we should write code as well as importance on making sure we always have a matching number of opening and closing symbols now with this basic knowledge we are now ready to learn one of the basic building blocks of programming which are variables so let's learn that in the next lecture hello and welcome I'm your KMI in this lecture we're going to learn all about variables what they are and what we can do with them okay so variables are one of the most important parts about programming in literally any language they are basically containers for data so we can define a variable which is going to be our container and then we can take some data and put it inside that container now variables also have data types which means different containers can hold different things so if a variable is meant to store a whole number I cannot place a text string inside of it there are some containers that can only hold numbers some containers Can Only Hold text others can hold true or false and a bunch more those are the data types which we're going to cover in detail in the next lecture and then we can also have some code I use a variable and basically when the code is executing that line of code in there when it reaches this point it is going to access this variable and grab the value from that variable so basically goes inside that container in order to grab the value that is stored so on the same line of code if we modify the value that is actually stored inside the variable basically we modify the behavior of our code so by writing code that uses variables instead of values directly by doing that we have a lot more control over exactly what our code is doing for example the exact same code to move a player can make it move fast or make it move slow depending on what value we store inside that variable okay so that's the theory now let's see how to make variables in code and the way we Define a variable in C is first we write the data type now there are various data types depending on what type of data we want to store like I said some store strings of text others store whole numbers others decimals and so on I'm going to cover a bunch of data types in detail in the next lecture for example over here let's store the simplest data type just whole numbers and for that we write in for the int data type this is an integer so basically whole numbers and also again like I mentioned in the last lecture it is extremely important that you write the code exact always remember how it's case sensitive so for defining the int data type it is exactly like this so int on lowercase if I make this an uppercase i then the code no longer knows what this refers to if I put the whole thing in caps then nope this is not recognized that as data type so once again always remember always write the code properly and perfectly so in this case on lowercase int so first we Define the data type and then we write the name for the variable the name can be pretty much anything you want there are only a handful of limitation like for example it cannot start with a number so this is not a valid name but for the most part picking a proper name like for example let's say age yep there you go just like this basically over here we are defining a variable called age which is of type int and now after defining the H variable we can do an equal sign and basically we can assign a value to this variable so let's say 35 with this we are assigning the value 35 onto the age variable so basically picking the value 35 and placing it inside the age container also it's very important that the value matches the type expected by the variable so over here I cannot write for example 35.2 this does not work this is an error because again in can only store whole numbers so I cannot store a decimal here so over here let's make sure to write a whole number let's say 35 and also as you write code you might see some symbols appear in kind of a faded gray as well as having the screens quickly lined underneath these are not errors these are pretty much as code suggestions so in this case it is saying that we are assigning this variable but the value is never used again that's because I'm writing the code slowly as I teach what it's doing so basically just don't get concerned with these green squiggle lines these won't go away as we actually use this variable so just remember these are not errors so don't worry about them okay so yep here we have defined the variable H and the variable is basically a container which is currently holding the value 35 if we want to inspect a value inside a variable for example one way we can do it is with the very helpful console that right line that we've seen up here so let's write the exact same thing and once again always make sure to write the code exactly perfectly so you can just do right line age and this basically going to print the age onto the console so if you go ahead and run this and if there it is it printed the value 35 so basically as the code goes to execute this line of code when it reaches this point it then looks inside this variable and pretty much just replace over here with what is the contents inside that variable so yeah great it's this simple here I have a demo in unity with this player character it is being moved using this move speed variable and basically it is currently moving at this speed and now if I take and I modify the value inside this variable there you go now it moves much faster or much slower so basically every time the movement function is running it is always grabbing the value inside this move speed so if we modify this then it modifies the actual Behavior so back in our symol console here here we have set the age to a value then we can also modify variables so for example let's print the current age so that it should print 35 then let's go inside the age and do something to it for example let's assign it to a brand new value and let's print the age exactly the same and let's see and if there you go now it prints both values both the original value and the updated value now instead of assigning to modify the entire value we can also do some math to it and we can also use the variable in whatever meth we want to do so for example let's say h equals H + 1 so this should increase by one so it should say 36 and if that go 35 and 36 also another way of doing exactly this so incrementing by one is you just do Plus+ so both these lines of code are doing exactly the same thing both are incrementing age by one and yet another method of doing this is plus equals and then one so what we have here is exactly the same thing as we have up here so basically takes the age and equals H + 1 so over here h plus equals this does the exact same thing as up here so all these are really just different ways of writing the exact same operation although on this one on the Plus+ we can only do this once so this one only increments by one whereas these we can modify and put any value and of course here we are doing addition but we can do the same thing with subtraction so minus minus in order to decrement by one so all these also work and then on these two we can also do multiplication or division yep so over here we are taking the age and multiplying it by two and over here we are taking the age and dividing it by two however this short hand this one only works for incrementing and decrementing if we try doing slash slash nope this one becomes a the common doesn't actually make a division so there's lots of math operations you can do with variables and also up here when you define a variable you don't necessarily need to assign a value right away so this over here is perfectly valid code however like the red Squig line says over here use of unassigned local variable meaning we need to actually assign a value before we actually use it so this is valid code but before we use it we need to assign it to something so for example like this and Yep this does work also another thing is how you can Define multiple variables at once so you define the type and then Define the variable and then a comma and then any other variable you want so for example an in for age in for health in for power something like that so we have defined three variables and then we can just assign values to them Yep this works or alternatively we can also just Define and assign multiple of them right here Yep this is also valid code then I should also point out that you can do math directly on the variables like this or you can also do it directly inside a function call so for example over here H+ 2 let's just erase both of these so that one should say first 25 and then 25 + 2 and if you go 25 and 27 but for example let's say you want to print out the age and then the health if you do age plus Health if you do this the that actually prints 125 instead of actually printing out both values both as separate things that's because both of these These are both numeric values so it basically ends up doing math with both these if you want to print out both values then you basically just need to convert these into a string that way they won't do any mathematical operations so the easiest way is up here we just had a quotation marks this basically marks the beginning of a string and then another one to Mark the end of it again remember all have matching ones so inside the string we can add anything like for example a comma and then we add a plus and like this basically an INT Value Plus a string it's going to convert the whole thing into a string then add another int which is also going to be a string so it should now print a string that will both print the age and the health and if there it is just like this okay so here we'll learn how variables are really basically just containers for some data and then you can do some operations to modify that data and speaking of data importantly is how each variable has a specific data type so let's learn about those in the next lecture hello and welcome I'm your Cod monkey so here let's do a walk through of everything in the variables lecture so basically I'm going to manually do everything that you should do after every single lecture so we just saw the variables lecture so let's open up over here the main window let's go inside the lecture list and this case we were following the variables lecture so let's go inside of that one and let's do them one by one so let's begin with the frequently asked questions these usually provide some extra clarifications on the topic on the lecture so in this case starting off with the basics so what exactly is a variable a variable is a container for data so think of it as a box and inside that box you can place some kind of value then you can write code that uses a variable instead of a value and by doing so when the code executes it will go inside that variable grab the current sord value and continue running the logic using that value this also means you can have different Behavior depending on the value stored inside the variable the simplest example is just a player object with some movement code instead of writing the movement speed directly you can define a variable and by modifying the value stored inside that variable you modify how fast or slow the player moves so variables are basically just containing to contain some value next why are data types important so each variable needs to have a certain data type and that data type defines what type of data we can store inside that variable there are data types for storing numbers and if you define a variable of that type then you cannot store a string of text inside that variable you always need to use the correct data type for whatever dat you're trying to store and the next lecture covers data types in detail so yep every variable needs to have a certain data type and based on what type you choose that defines what type of data you can store within that variable next what is a good name for a variable this is a great question so a good name is something that describes exactly what that variable represents ideally just by reading the variable name you should be able to understand what it represents and how it might be used for example a move speed variable this is a good variable name it clearly communicates that this is a variable that is used as some kind of movement speed whereas a bad name would be X just by reading it you have no idea what it represents unless of course you're making some kind of meth equation and X really is the correct name for that element so you should avoid abbreviations and acronyms those might be perfectly clear to one person and very confusing to someone else there is a very very important lecture later on in the course all about naming rules and how to choose good names next question what happens if I write int with capital i instead of int and the answer is you get an error because there is no such type named int with a capital I so always remember that code is Kate sensitive the compiler does not know English so as far as the compiler is concerned int with uppercase and in lowercase these are two completely separate types with no relation between them whenever you get an error the first thing you should should check is if you're writing the code absolutely perfectly pay very close attention to capitalization this something that a a lot of me mistake and Y this is something that I will continue repeating many times throughout this course code is case sensitive I see many beginners make this mistake on the many comments that I receive so I'm repeating it nonstop because I want to make sure that you don't make the same mistake next question what is console.
Right line so this is a function that rites to the C console the console this is actually a class and right line is a function within that class but like it says here don't worry about functions in class right now those are all explained in detail in future lectures for now just know that it prints something to the console and the alternative in unity is this it is a simple debug.log basically if you're working in a console app use console. right line and if you're writing some code inside a Unity script for that the related one is debug.log and in doing so it will print some kind of message down here on the console next question what are the various ways to increment a variable and yep all of these lines of code are doing the exact same thing incrementing a variable by one so you can do H equals H+ one that will increment by one you can do AG plus equals 1 that won't do the exact same thing so grab Ag and increment by one or h++ which again same thing increments age by one all three of these lines of code these all do the exact same thing like it says here these are just short hands the last one is especially useful when working with loops which we're going to learn in a future lecture next and final frequently Asked question what if I Define a variable but don't give it a value if you don't give it a value then the variable is uninitialized and cannot be used until you give it a value so if you do something like this you get an error so defining int age and then trying to do a constant on the right line using AG if you do this you get an error because it says that the variable age is uninitialized although later on the course we are going to cover classes and class variables and if you don't Define a value for those it won't default to a zero value so the zero value that means something like zero for an N Field means false for a b field or known for a string field again class are covered in detail in a future lecture all right so yep those are all the frequently asked questions as you can see they contain a bit more detail a bit more specifics on what was covered in the lecture going back in the main window we can see we have completed all seven frequently asked questions now let's go through all the quizzes starting off with the first one right here what is the primary purpose of a variable in C so is it to name a function to store data to execute commands or to create new data types hopefully if you fully paid attention to the contents of the lecture you should be able to answer all of these quizzes correctly so in this case the primary purpose if variable in C the primary purpose is to store data and if that is indeed correct here is the answer with some more details variables are containers for data you define the variable and then put inside whatever value you want based on the data type then you can write code that uses that variable in some way and when that code executes it goes inside the variable container grabs the value that is stored inside it and uses that value to continue running the code next question which of the following is a correct way to declare an integer variable so is it integer age equals 35 is it int AG int with uppercase i or all uppercase int again yet another example of how important case sensitivity is for example if you were to incorrectly choose let's say this one with capital I nope this one is not correct the correct one is that all lowercase answer always be very careful with how code is case sensitive int and uppercase int might look similar but they are two completely different things the biggest mistake that beginners make is writing code carelessly and then have no idea why it isn't working so always pay very very close attention to capitalization write the code exactly as it should be next Quiz how can you modify the value of a variable is it by assigning a new value to the variable by using the modify keyword or by redeclaring the variable with a new value so if you redeclare you're going to get an error because you cannot declare two variables of the exact same name and there's no such thing as a modifi keyword so the correct answer is by assigning a new value the answer here you can define a variable and then assign a new value to replace the previous value so Define in h equal 35 and then replace it with 25 like it says here you don't redeclare it if you do you get an error since you cannot Define two variables in the same scope with the exact same name so over here if you do this yep you get an error age is already defined however you can also have multiple variables of the same name as long as they are on completely different scopes for example you can have a local variable named age inside one function and a different local variable on a different function also named age there is a detail lecture on scope later on in the course next Quiz what does the statement h++ do so does it reset the value of H to zero does it divide the value of H by itself does it increase the value of H by one or multiply the value of H by two this one is a short hand for increasing by one so yep it increased the value of H by one like it says here the shorthand for increasing the value sored in the variable by one this is a really super useful shorthand especially when working with loopes which we're going to cover in a future lecture these are the two main shorthands so h++ and H minus minus although these two do not work you cannot do age multiply multiply this doesn't work or divide divide also doesn't work so this shorthand only works for these two but if you want to do this kind of math so multiplication and division if so you can use these other short hands so plus equal 2us equals 2 time equals divide equals next Quiz question what math operations can you do on a variable so is it only addition is it addition subtraction multiplication and division or is it only assignment of values any up with variables you can do pretty much all kinds of math so the answer is this one you can add plus Subtract with minus multiply and you can divide although of course this assumes that the data type being used in the variable is a number type naturally you cannot multiply a string or divide an object next multiple choice question is it possible to declare multiple variables in one line so yes by separating them with a comma or no each variable must be declared in a separate line and yep if you use a comma you can indeed Define multiple variables in one line so yep you can do this this is perectly valid code so int age comma in health and so on this works although at the same time while this is valid code personally I tend to avoid doing this because I feel like makes the code a bit more confusing so while you can do this personally I would always Define each variable in a separate line just to keep the code nice and readable next Quiz question how do you print the value of a variable to the console is it with console. right line and the variable name is it console. print or just right line and this is something that you're going to do tons and tons of times so even if you get it wrong right now you will certainly get this right soon enough the answer is this one consant outright line a very common function you use consant outright line whenever you want to print anything onto the C console and by the way if you don't understand this syntax then don't worry this is a function and a static class all of that is explained in detail in future lectures or alternatively when working with unity the similar function that prints with unity console that one is called debug.log and then you print whatever you want okay so final quiz question what does the statement age star equals two do does it divide value of age by two does it in by two or multiplies by two and yep I'm pretty sure that the star is the universal symbol for multiplication so yep this one is the multiplication the srisk means multiplication and this syntax is a shorthand for doing sum function on the left side so these two lines of code are doing the exact same thing so H star equals 2 or H equals H * 2 yep both these are doing the exact same thing all right so that's the questions and we have 8 out of8 done now let's go into the exercise and let's go through all these one by one this one is a really really important part after you go through every lecture definitely make sure you do all of the exercise so let's do them beginning with this one okay so lecture variables exercise titled Define speed variable the goal is to edit the script exercise.
CS we need to declare a variable of type int with the name speed and assign the value five to it so pay close attention to where you write the code so here's a quick hint right inside the main function so let's open up exercise. CS okay here is the file and right away there's just a quick explainer about what are these things in green these are commons these are just text the compiler completely ignores this so none of this is read as code comments are going to be covered in detail in a future lecture so the goal is to write some code after this line but again very important like I mentioned in the lecture on programming Basics we need to write it inside the main function so right here the goal is to declare a variable of type int with a name speed and the value five so like we learned in the lecture first we write the type name so in this case we want an INT and again always keep in mind code is case sensitive so it's in all lowercase it is not uppercase if you do it like this we got a red squiggle line int is not being recognized so the type name is int then after the type we write the name so in this case we want it to be named speed and then in order to assign a value we need to use the equal sign and then whatever value so in this case let's assign it to the value five and Yep this is it now since this is the first exercise let me just show a few things so for example if we make a mistake here so if we write int with uppercase again very important before you go back into Unity you have to save so either go up here into file and then save or just press contrl s so as soon as you save Unity should see the changes and it should start to compile or in this case we have a compiler error so it doesn't actually compile and like I mentioned on the lecture on how the exercise work always make sure you have the companion window open that way if you make some kind of mistake that leads to some kind of error here you can see a little bit more text that might help clarify exactly what the issue is so over here the issue is pretty simple it's because we wrote in incorrectly so as always remember how code is case sensitive so over here we need to make sure to type in and again if we also make another mistake St here like we named sped instead of speed right now the code is compelling because we have no syntax errors any you the exercise is still in progress because we didn't actually compl it perfectly and again down here on the companion window we can see some nice helpful message so did you accidentally write something different again the goal with this exercise is to teach you how to write things absolutely perfectly so now let's properly construct our exercise so just like this so Define a variable of type in named speed with the value five and if we save and just let the code compile and if there it is we have the ex SI completed then we can also show the hint like the hint says here remember the Syntax for how variables are declared so first the type and then the name and then optionally assign some value always remember how code is case sensitive so Define variable named exactly speed not uppercase speed or anything else and if we were to get really stuck we can just show the solution and up here we see the goal is to Define a variable of type in named speed with the value five so the solution is exactly this so in speed equals 5 and if we want we could click on apply solution any if that overrides file with one with the solution which is exactly what we wrote so yep just like this so like it says here congrats in this exercise you applied what you learned about how variables are defined how they have a type a name and a value so if that's it now click the complete exercise button order to finish the exercise all right here is the lecture on variables let's see the exercise titled fix error in so like it says here edit the script exercise.
Cs and fix all of the compile errors and by the way as soon as you start the exercise or click on this button to open the file and if you do and if you see Unity kind of breaking like this if so then go into your visual studio and over here you might see this window telling you that some file has been changed externally that's because the whole setup for starting the exercises so whenever you see this window just go ahead click on yes to all and yep it should reload everything and yep here is the exercise file again the goal is to fix this error and here's a quick tip place the mouse over the red line in order to see the actual error so if we place the mouse over here directly on top of the int Red Square line if so we can see this here the typ Oro namespace int could not be found and like it says here alternatively we can check the unity console or check the companion window so here in unity if we look at the console yep we see exactly that error tyer name space in could not be found and over here on the companion window over here we can see a nice little hint on what exal the is might be and Y in this case this teaches us exactly what is the solution what is the problem that we have here as always remember how code is case sensitive then we can also show the hint so in this case the hint is pretty simple so remember how code is Kate sensitive and we can also see the show solution so there's an that says int uppercase i does not exist and that is because code is cons sensitive and the proper name is in all lowercase so the compile error here is pretty simple remember how you have to write code perfectly so in this case it is not int uppercase but int all lower case so y that's really it let's go ahead and save the code is compiling and if there it is exercise completed okay so congrats in this exercise you'll learn how to solve the most common error that beginners encounter which is issues with capitalization always remember how how code is case sensitive so in on lowercase and int with an uppercase i those are two completely different things one exists and one does not same thing for all the other types so float versus float bull bull true true and so on so once again another exercise to really make sure you fully understand code is K sensitive the reason why I'm repeating this so often is really because this is the main error that beginners encounter okay so we can now complete the exercise all right so lecture on variables here is the exercise change unit speed so the goal with this one is modify the speed variable to make the player reach the Target in time this exercise has a Unity scene it should be unloaded automatically so click on play in unity to test your code and just a quick tip just in case the scene doesn't load automatically it should do that but in case it doesn't just go into your project files and if you scroll down you go into whatever lecture you're currently on So currently we're on the variables lecture and over here if we go inside the exercise folder we should be able to see all the files for this exercise so over here we have the exercise scene and yep it is this one so like it says here the goal is to modify the speed variable now before we check the code let's try running this code and see what happens so the player is moving some kind of player character it is moving and nope it did not reach the Target in time okay so we need to modify the speed in order to make sure it gets there on time so here is the code and again you can ignore these lines that start with two for slashes these are comments and the code ignores all of these lines comments are covered in detail in a future lecture so here we have a line of code that is setting some kind of player speed variable so all we need to modify is this valum and then we can press play in unity to test our code and again something that is going to happen more and more as we see some more complex exercises is some of them have some testing codes so just make sure you don't modify these lines of code otherwise the exercise breaks so in this case all we want to modify is this one and if we get stuck we can always show the hint and like it says here variables
The words are the caption track's own and nothing is reworded or re-transcribed. Paragraph breaks are placed between sentences so the text reads as prose.
Free tools for your own script. No signup, no login.
Paste your draft and see where viewers are likely to drop off, with a rewrite for each weak line.
Paste the first 30 seconds of your own draft for a hook score and rewrites.
Check your draft against YouTube's advertiser-friendly guidelines before you record it.
Read this channel's public videos and transcripts, and download a writing brief for it.