So now that we know a bit about object oriented thinking, let's dive into how to create C# Scripts and their anatomy. From the Unity editor, you can create a C# Script. C# is a popular, powerful object oriented programming language used not only in unity, but in many software development domains. As a programmer becoming an expert in C# will serve you well, careerwise even outside game development. The script that you create becomes a game asset, just like graphics or audio files and shows up in your project assets. You typically edit scripts in a tool external to Unity, such as one of the versions of visual studio. Scripts, when attached to GameObjects, become components of the GameObject and appear in the inspector, just like other components. Set another way, a script, which defines a class is instantiated to become an object when it is attached to a GameObject. When you create a new script, Unity will give you a template script similar to this script. Then using lines at the top just say that this script should use the Unity engine and system collections namespaces, that is the namespaces should be part of the script. This just makes it easier to include references to code, related to the Unity engine and the system collections within this script. If you are new to C#, and this doesn't yet make sense, don't worry, just keep the lines at the top that unity automatically adds to your scripts and ignore them for now. The next line defines the class, the name of the class basic target mover in this case needs to be the exact same name as the file name for the script. If the class name and script file name do not align, you'll get an error and Unity. If you change one of the names you need to change the other as well. The :MonoBehavior means that this class inherits from the MonoBehavior class. Mono is an open source implementation of Microsoft's .net framework. Unity scripts are built on top of mono, what this means is that if you're already a .net programmer, your knowledge will apply to Unity. If you're not, you will build skills as a .net programmer by programming in Unity. The behavior portion refers to a script that is attached to a gameObject. That is, if you want to write a script for a gameObject, it should inherit from the MonoBehavior class. Within the class definition, you define class variables, typically at the top of the class, these are often called properties of the class. And then you define class functions, these are often called the methods of the class. This section often is the mid of your code. You typically define variables within classes, you can think of these variables as properties of the class. When you define variables within a class, if you make them public they appear as properties of the component within the Unity editor inspector. For example, here we define two public variables, one of type boolean called doSpin, which is initially set to true. This variable shows up in the inspector as a checkbox, checked for true or unchecked for false. The other variable is of type float called spinSpeed, which is initially set to 180. You can see that this variable also shows up in the inspector and can be changed within the editor from the default value set in the script. Notice how Unity changes the variable names into a more human readable version in the inspector automatically. You can also, create private variables that are used solely within the class, these are not shown in the editor by default. If you create a variable and do not specify it as public or private, it will default to private. Typically, you define functions within the class, here you can see we have a start function and an update function defined in this class. These two functions are named as they are responding to events that occur in the Unity engine. For example, when we click the play button in the Unity editor, the start event occurs. If this script were attached to a gameObject in the scene, the Unity engine would call the start function on this script, and any other script with the start function within it. Every time the frame updates, an update event occurs, this will cause the update function to run. And it will run each time the update event occurs, which is typically many times per second. So overall in the script, the start function will run once when the game object first appears in the scene. And the update function will run over and over while the gameObject exists in the scene. Typically on each frame update, which we call the game loop. So as a quick review, this is the anatomy of a typical C# script, including the using section, the class definition, a listing of class variables and the class functions. [MUSIC]