Learn Unity in 17 MINUTES! [2024 UPDATED PINNED COMMENT]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
In this video, we're going to learn Unity in under 20 minutes. Game objects, components, scenes, physics, and more. Alright, let's begin. Okay, so first things first. Let's cover how Unity versions work. Right now you can get version 2019 and 2020. The 2019 version is in long-term support, which means it's extremely stable. Whereas the 2020 version is in a tech release, which means it is being used for testing new features. So that means that for most cases, you want to use the most stable version, which in this case is the 2019.4, which is what I'll be using here. Now, as soon as you download Unity, you're actually going to download the Unity Hub. This is the program that manages all your projects and Unity versions. So you've got the Projects tab with all your projects. You have the Learn tab with a bunch of official learning content from Unity. Then the Community with a whole bunch of links and the Installs, which shows all of the editor versions you have installed in your machine. So here in the Projects tab, let's hit new and we get this new window. Now in here we can see a whole bunch of different templates. They will simply set up the starting state of your project, so don't worry too much. For example, if you select the 3D template, you can still use 2D or vice versa. Now these two down here are for the two separate render pipelines. The high definition Render Pipeline is focused on giving you the absolute best visuals, and the Universal Render Pipeline is focused on making your project run on anything. So if you're an indie game developer, chances are you'll be mainly working on the Universal unless you're trying to push the limits with the visuals. Now, in this case, we want the simplest thing possible. So let's just select the basic empty 3D template. Let's just give it a name and just hit Create. And yep, here we are in our brand new empty project. So over here we have our scenes starting with light and just a camera. So everything is completely empty. So we have a real nice blank canvas where we can create anything. Now right away we see the default Unity layout. You can see that there's lots of tabs everywhere. So for example, here is the Scene view. Then over here is the Inspector and so on. By clicking and dragging, you can move them around so you can place them anywhere. So you can customize the editor to look exactly the way you want it. Now I'll cover what each of these windows does in a bit, but first let's set up our layout. Now for me, I've been using Unity for a long time and this is the layout that I found best, so the Inspector is nice on the right side, always visible. Then I place the Hierarchy down here. Then the project files here next to it with the console. Then on the project files, I also like to see them on a standard explorer view. So just go in here instead of the two column layout, I prefer the one column. And just like that, you can see everything. So that's the project files, and next to it, again, the normal console. And up here a nice big view of our scene view. And next to it we have our game view. So this is the layout that I normally use, but again, all the windows are customizable. So if you prefer something different, by all means use that. You can drag and place any window and place them anywhere. Okay, so now let's cover what each of these windows actually represents. Now, right down the middle we have our scene view. So this showcases everything that you have placed in this scene world. For example, I can place an object. So I go down here to this plus, create a new 3D object. Let's make it a cube. There you go. Just like this, I have a basic cube right in the middle of my scene. You can also see these handles. So these allow us to move the object. So for example with this one, I can move it just on the X-axis, moving it on the Z-axis and on the Y-axis. Or just any of these and move them around. Now this is only the editor's scene view. It is not the game view. If we click on the game view, then now we are actually seeing what the camera sees. Whereas in the scene view, we are free to roam around and look around from any perspective. Now for the other windows down here, we have the Hierarchy. So this shows all the objects that currently exist in this scene world. Up here we have the name of our scene, our sample scene, and here are all the objects inside of this scene. Then here on the right we have our Inspector. This shows detailed information of whatever object we select. So on the Hierarchy, we simply click to select an object, and yep, it shows the object over here in the Inspector. It shows the object name up here and all the components attached to that object along with all of their fields. Now I'll cover components in a bit. Then down here we have our project files. So this is just the folder structure for your entire project. So if you right click and click on Show in Explorer, it opens up the basic Explorer and you can see that all of the assets in here in the project files are the ones inside the assets folder. So as you can see, we have a Scenes folder, and inside we have our Sample scene. Alright, so those are the basic windows. Now let's go back here into our scene view window. And again, here we can see the entire world view of this scene. So in terms of controls, everything is pretty basic. So we can select objects by left clicking on them. Then we can look around with right click. If you press Alt and left click and drag, you can orbit around a certain position. You can zoom in and out with the mouse wheel. to pan around, you can use the middle mouse click or alternatively up here, use the hand tool, just hand and just left click. You can also do freeform movement. So with right mouse button down, looking around and we can move using W, A, S and D. So just basic as if it was a normal game. we can increase and decrease the speed with the mouse wheel. So press mouse button down, mouse wheel up, and there you go. Now we're moving at 2x speed, move it down, and now we are moving very slow. And if you get way too far away from a certain object, you can, for example, select over here on the Hierarchy and press the F key. And there you go, it zooms in straight on the object. So the object zoomed in, and for example, if I orbit around now it orbits around the object. Then up here we have our toolbar. Now we already saw the hand tool, which is used for panning around. Then we have the move tool, which shows all of our movement axis. So moving the X, the Z, the Y, or any of them. Then we have the rotation tool, which again, we can rotate individually on each or rotate on all of them at once. Then we have the scale tool, so we can scale on the Y, scale on the X or scale on all of them uniformly. The next to it is the Rect tool. So this one also modifies the scale, but it does so on a different way. Now this tool is mainly used when working in the UI. And finally we have the Combined tool which combines all of them. So over here we can move, we can scale, and we can rotate all of them. Alright, so that's the controls and all of our basic tools. and all these tools can be accessed with the keyboard. So press the Q, and now we have the hand tool. Press the W, we can move. Press E, and we have the rotation. The R, we have our scale, and T we have the Rect tool. And with the Y, we have the combined. All right, so that's the controls and the basic tools. Okay, so now that we cover the interface and all of its controls, let's see the basics on how the engine actually works. Now, as you already saw over here in the Hierarchy, we have a list of all of the objects in our scene. They are technically called game objects. So a game object is the main building block in Unity. It's the base for every object in your game. With game object selected, we can look over here in the Inspector and right away up here we see the name of the game object. So you can change this to whatever you want. As you update, you can see that the name also updates on the Hierarchy. You can also click on this button in order to add an icon. So for example, let's add this one. And now on the scene view, I can see the icon there. Now a game object can have components attached to it. Unity is all about composing a game object with various components to get the behavior that you want. So for example, let's go up here and just create an empty game object. So I created, and there you go, there's the game object, there's a name, and by default it has a Transform component. So every game object always has a Transform component. Now this component stores the game object's position, rotation, and scale. So this is the name of the component and these are the three fields for it. By adding more components, you add more logic and behavior to your objects. So by itself, this empty game object doesn't have any visual at all. So in the scene view, we can move our object with our handle and we can see that it's moving the transform, but there's no actual visual. In order to actually see it, we need to add some sort of visual component. So for example, let's add a mesh component. So we click on Add component, and over here we can manually select from any of these groups. So in this case, we can go into mesh and click on the mesh filter. Or alternatively, we can use the search bar and just type in mesh. And there you go. We have our mesh filter. and now we can see the fields related to this specific component type. So as you can see, they are different from the transform. This component requires a mesh. So we can click on this button here in order to select a basic mesh. So we click on it and we get this window. So here we can see all the meshes currently available in our project. So we have all of our defaults. So let's select the basic cube, and now we still don't see anything. That's because this component only stores a mesh. It doesn't actually have a visual. So in order to visualize this mesh, we need to add another component. This one will be the mesh renderer. And as soon as we add it, now we can indeed see our cube mesh. So the mesh filter has a single purpose, which is to store a mesh. And the mesh renderer has a single purpose, which is to render whatever mesh it has. So here we see all the fields that define how this object is rendered. And right away we can see that our mesh is actually in pink. Now the reason for that is because pink is the default color. So when you don't have anything assigned, it won't render as pink. What defines the rendering is over here, the materials. So materials are what defines how an object is rendered. We can create a material by going over here into our project files, click the plus button, and over here we can create a whole bunch of stuff. And let's select the material. Now we have our material. Let's give it a name, our cube material, and here it is, our material in the Inspector. Now each material uses a Shader up here. This is what defines the various properties of that material. So for example, if we select the very simple shader, there you go. This one is extremely simple. Only it has a basic film for a texture. And if we select the more complex shader, like the default shader, this one has a bunch more fields related to how they interact with light and normal maps and so on. So with this standard shader, over here we have a field for the Albedo. This what defines the actual color of the object. And over here we have a little square and then our button to select something. So if we click on it, now we see all the various sections that we can use with our material. For here, let's just select one of the default textures, and just like that. down here we can see a preview of what our material looks like. We can also play around with making it more metallic, more smooth, and so on. For now, let's leave it all at the defaults. Okay, so we have our material. Now let's go back and select our object. Then we have the field for our material, and we can again just click in here and select the material. Or alternatively, we can click and drag from our project files and drag it right in there. And there you go. We have our material being applied to our mesh. Alright, awesome. So far, so good. So we made the game object. We added the component to add a mesh, then we added another component to actually render that mesh with a specific material using a specific texture. Now again, Unity is all about components attached to game objects. So we can keep adding components to add more logic and behavior. For example, we can click on add component and let's add a rigid body component. So this one will make the game object exist in the physics world, which will make it fall down with gravity. So let's make sure that the game object is positioned in front of the camera. So you can see the camera's here, the camera's being in there and yep, there you go. The game object is indeed in there. Alright, so now we can try to hit play. And right away we see our object follow along with gravity. So as you can see, it's extremely simple to add physics interactions. Just add a rigid body component. And there you go. Now it's being affected by gravity. Now, by itself, the rigid body doesn't have a physics shape, so in order to do that we can add another component. So in this case, let's add a sphere collider. So in the shape of a sphere, and let's change our mesh from a cube. Let's select our sphere. There you go. So we now have a visual sphere along with a rigid body and a sphere collider. Now let's try creating a new plane. So clicking here, create a new 3D object. Let's make a new plane. let's put it underneath the sphere. Now by itself when you create a plane, you can see that it already has a mesh filter, mesh render, and also a mesh collider. So this shape has collisions. And if we run, there you go, the sphere falls and falls right on top of the plane. Now if we just slightly rotate the plane and test again, and there you go, the sphere falls along with gravity. And since the plane is slightly rotated now it's gonna roll away. So it's rolling, rolling and yep, there you go, it goes falls down. So as you can see, that's how easy it is to add physics to your game. You just had a collider and a rigid body and just like that, we have some really cool physics interactions. So as you can see, a game object is the base building block in Unity. It can have components attached to it, and those components are what defines how the object looks and behaves. Each component has a purpose. You can browse around this add component list to see all the components that are available by default. And you can also obviously make your own scripts and add them as components your game objects. Now to make script, we just go into our project files. Let's right click here on the assets folder, go into Create, and let's create a new C# script. Let's call this our custom component. And now when you install Unity, it also install Visual Studio and linked it with the editor. So just by double clicking on this file, it should open up Visual Studio. And yep, right away we see our default script. Now here I'm just covering an overview for how the engine works, so I won't go too deep on scripting. By default, you can see that we have the start and update functions. So the start is called once before the first frame update. And the update is called once per frame. Now one important thing that you can see here is how it extends MonoBehavior. This is the base Unity class that all scripts must extend if you wish to use this class as a component. So let's leave it as it is and let's go back into the editor. And here we can add our custom script as a component to our object. So we can either click on add component and find our custom component. There it is. Or alternatively, we can just click and drag from here and drop it right in there. There you go. There's our custom component attached to our game object. Now just for testing, let's go back into Visual Studio. And in here, let's add some messages. All right, so I'm just calling the Debug log function. So this function simply logs a message to the console. So there's one on start and one on update. So now if we go back into the editor and if we run our game, and now down here, if you look on the console, yep, there you go. We can see our messages. So we can see that the start ran just once. And then we've got updates being called on every single frame nonstop. Okay, awesome. So that's how custom components work in Unity. Now another thing about Unity is how it works both in 2D and 3D. So over here, if we select our main camera, we can see that it's a 3D camera and on our sphere we have a sphere mesh, but we can easily change this to 2D. So instead of a mesh render and a mesh filter, let's instead add a component of type Sprite renderer. So this one displays a 2D Sprite. So in here we click on this button, let's select one of the default ones. So let's say this one. And there you go. You can see the Sprite. Yep, there you go. That's a Sprite. So you can see that it is completely flat. So yep, just like that. So that's how you make it to the visual. And now on the camera right now, you can see this is a perspective camera. So over here we have a field of view. So we can swap it out. Over here we have the projection and we can swap the projection from perspective and put it in orthographic. So now, as you can see, yep, it is a flat 2D. Okay, so we're back here on the scene view. And now down here we see the Hierarchy, which shows every object in this scene world. So let's quickly cover what are our scenes. Now scenes are one of the main ways you have of organizing different parts of your game. So for example, you would have a scene for the main menu, another one for the game, another one for a different part of your game and so on. You can easily create a scene by going to the project files, click on the plus sign, and over here we create an new scene. Let's call this our second scene and double click to open it. And yep, right away you can see that we no longer have the objects we had in our scene. So we're back into a default empty scene. So down here we can see the Hierarchy. Yep, we just have the camera and the light. And if you go back into our original scene, our objects are all still here. So as you can see, they are in completely separate worlds. You can have as many scenes as you'd like to help you manage your game. Alright, so you just learned the basics of Unity in under 20 minutes. Now that you know the basics, you can go follow some more complex tutorials. Unity is extremely versatile. You can use it to build very simple or very complex games. So anything from shooters to point and clicks to deep simulations, the only limit is only your imagination. Alright, if you found the video helpful, hit the like button and subscribe to the channel for more videos. Post any questions you have in the comments, and I'll see you next time.
Info
Channel: Code Monkey
Views: 1,265,170
Rating: undefined out of 5
Keywords: how to make a game, unity basics, unity beginner tutorial, code monkey, unity beginners guide, unity basics 3d, learn unity 3d, unity beginner scripting, unity learn, unity tutorial, unity game tutorial, unity tutorial for beginners, unity 2d tutorial, unity 3d, unity, game development, game dev, unity 2d, unity 3d tutorial, programming, coding, c#, code, learn to code, learn programming, unity tutorials, unity 2024, unity 6, learn unity 2024, learn unity 6
Id: E6A4WvsDeLE
Channel Id: undefined
Length: 17min 27sec (1047 seconds)
Published: Mon Jul 20 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.