 All right, so let's now turn our attention to our input script and start to capture all the inputs that the user is providing. So in this case, what we're gonna do is just use the keyboard and the mouse to set up where the reticle should be placed and where the actual turret should be pointing towards. And we're also going to capture just the vertical and horizontal axis on the keyboard so we can move the tank forward and back and turn it left and right. All right, so we're gonna take a look at a couple of C-sharp components here, most notably the C-sharp properties. And this will just allow us to protect our data but still allow other scripts to access the data without having to mess with it. All right, so let's hop over into Unity and take a look. All right, so let's focus on the inputs here. Okay, so if you remember from the last video we automated our setup for our particular tank controller here. Okay, so let's pop open the tank inputs here and let's go in and start to set up our regions. As you can tell, I do this all the time before I actually dive into coding anything because I like to organize and just keep everything nice and clean. It helps everybody out on your team and even if you are just a single developer it helps you out as well. It just keeps your sanity so you don't lose your place, especially if you come back to your project after a week or a month, a year, you know what I mean? So what we're gonna do, in order for us to actually place the reticle where the mouse is pointing we need to get a position from the camera, all right? So the camera is going to be our main controller for that reticle position, all right? And to do that, what we need to do is we need to provide the camera that we wanna use to place the reticle, okay? So if we jump back into our script over here I'm going to place down a public property or variable here that is gonna take a camera, so a type of camera, and I'm just gonna call it camera, all right, so that is the camera that we want to provide. So the next thing I wanna do is put a little header over this. So these are one of those attributes that you can put into your scripts just to give a little bit more information about what these particular properties are for, these variables are for, okay? So I'm just gonna call this the input properties, just keep it nice and simple, nothing crazy. And for our script, we're probably not going to need the start method in this case, okay? We don't really need to initialize anything. So it's a good idea just to keep your scripts nice and clean, if you're not gonna use any one of the built-in methods, just get rid of it. Which just helps keep everything nice and clean, okay? So at this point, what we wanna do is, I wanna say if I have a camera, all right, I'm gonna run some functionality, okay? So I want to create my own custom method, as they're referred to inside of C sharp. So I wanna go here and say, I wanna run all the code that is in some method that we're gonna create here pretty soon called handle inputs. And the reason why I like to do this is because I wanna create methods that are flexible, okay? So I'm gonna call this the region of custom methods. This is where I'm gonna put all my custom code, all right? And like I said, the reason why I do this is because I wanna keep this handle inputs a flexible method. And by flexible, I mean, I wanna be able to override the functionality in it just by creating another script and saying that I can override that particular method. I don't wanna have to go and set up another script with all this functionality in it. I just want to keep that in our base script here in this tank inputs. And I only want to override the method that's handling the input. So to do this, what I like to do is use the protected virtual void, all right? We'll call this handle inputs. Now, that probably needs a little bit of an explanation, all right? So when we say that something is protected, it means that no other class outside of this class can actually access this particular method unless it inherits from this particular script, all right? So this is one of those first steps into polymorphism and inheritance inside of C-sharp. So what happens is if I wanted to create a different type of inputs for my tank, I would create another script. I would inherit from this particular script. I wouldn't inherit from MonoBehavior. I would just inherit from this particular script. And I would then just override the handle inputs. So then I wouldn't have to rewrite all of this code right here, all right? It's in the base script, okay? So while I'm here, let me actually scale the code up a little bit for you guys. I know that in the past, a few individuals have said that the code need to be bigger. So hopefully that works for you, okay? So what I wanna do now is I wanna create a couple of C-sharp properties, okay? Because what I need to do when I move this particular reticle around, let me get back into Unity here. When I move this particular reticle around, I need to store the position that we want the reticle to be at. And I wanna store the normal information, all right? So let's jump back over into Visual Studio here, all right? And what I wanna do is I'm gonna create another region, okay, and I'm gonna call this my properties like so, all righty? And I'm gonna create a private vector three, all right? So a vector three stores x, y, and z information. So position in world space or local space, right? I'm gonna call this the reticle position like so and make sure I name that correctly. And to actually make a C-sharp property to allow another class to access this particular variable, okay? We need to write public vector three, all right? We're gonna call this reticle position. And then what we're gonna do, it's gonna look kind of like a method, but these are C-sharp properties. Because what I want this to do, okay, is I want another script to be able to access this particular property, but currently it's set to private here, right? Which means that only this particular class has access to this vector three variable, all right? So what we wanna do is we want to allow another script just to get the information from this particular variable here. We don't want it to set it as well. If I were to make this public, that would mean that any other script could also set the variable, the data inside that variable, okay? So I'm gonna make it private so it can't do anything with it. And we're gonna allow another script just to get our information. So I'm gonna say return the reticle position like so. All right, so let's do the same thing for the normal. All right, so private vector three reticle normal. And I need to make sure I put the semicolon there. All right, so we're gonna create that property now. We'll call that vector three. And it's gonna be reticle normal like so. And we just wanna get the value. We don't wanna allow any other script to set it. There we go. So that's C-sharp properties. Let's just a quick overview, really. All right, there's quite a bit. You can actually have a code that actually runs in here as well, but I don't really wanna dive into the nuts and bolts of C-sharp. I'm gonna save that for the C-sharp series, all right. That is definitely gonna be coming soon. And I promise you guys I'm going to do the full on indie pixel intro to C-sharp for Unity 3D, okay? So I promise. All right, so moving on. Now that we have all that information, what we can do is we can come down here and we can say that we want to get a position from our camera, okay? So when I come over here into Unity, when my camera is hovering over the game view here, okay? What I want to be able to do is I want to be able to place the reticle wherever my mouse is. So in order to do that, we need to get a position from the camera and screen space and put it into world space so it hits the ground over here. So in order to do that, what I'm gonna do is come over here into Visual Studio and I want to create a new ray, okay? So this is a type of ray and we're gonna call this the screen ray, like so. And we can say that the camera.screen.ray, all right? This is the method that we're gonna use, all right? You can see that it returns a ray going from the camera through a screen point, okay? So our mouse position is our screen point, okay? So I'm gonna come in here and I'm gonna say input.mouseposition because that's our position in the screen, all right? That's the X and Y position on the screen. And what this will do is it'll return a ray that we can use then to cast into the scene and if it hits any sort of collider, all right? It'll actually return back for us a position of world space and a normal, okay? So to do that, what we're gonna do is we're gonna create a raycast hit, all right? This is gonna store not a raycast command, raycast hit and I'm just gonna call it hit. So this is gonna store that hit information for us because what we need to do is we need to say if physics.raycast, okay? So we're gonna raycast into the scene, okay? So if we do in fact hit something, all right? And in order to test if we hit something, we need to provide it a ray, all right? And that's gonna be our screen ray, all right? And we're going to put that information into this hit or this raycast hit variable right here and you can see we have a bunch of different overrides and this is the one that we're going to use right here. Okay, so we're gonna do our out. So we're gonna output the value into that hit variable that we created that local variable there, all right? All right, so if we hit something, all right? So if this method right here returns true, that means we hit something and it's gonna put all that data into this hit variable for us, all right? So if we hit something, then what we're gonna do is we're going to say that the reticle position is equal to our hit dot point and our reticle normal is equal to our hit dot normal, all right? The hit variable or this raycast hit variable stores all the information about what was hit by this raycast, okay? And because we are creating these private variables right here, we're storing that information in those private variables and then just letting another script access or get just the information using the public properties. So hopefully that makes sense. Definitely let me know if you have any questions about properties or the virtual methods right here. I'll be more than happy to answer that. All right, so with that, what we can do is we can actually start to test this just to make sure that it's working, okay? So what I'm gonna do is I am going to appear in the built-in methods. I'm gonna utilize another built-in method called on draw gizmos, all right? Probably used this before, but if you are new to Unity, I'll walk through how this works. So this allows us to draw little gizmos in the scene, all right? And these are just graphical representations you can use to visualize your code and your data, okay? Cool. So what I'm gonna do is I'm gonna say gizmos.draw, and we're gonna draw a sphere. So let's draw a sphere in the scene, all right? And now you can see that this particular method needs two arguments here. It needs a center or position in world space and a radius and that's the radius of the sphere. So we already have the position, all right? This is that reticle position, so it's that world space position, all right? We're gonna do reticle position and I'm gonna give it a radius of 0.5, all right? So with that now we're drawing a sphere in the screen. What I wanna do now is I wanna differentiate it by giving it a special color. So I'm gonna say color.red, all right? And there's a bunch of built in colors instead of all of this, instead of C sharp. I'm gonna use red though for now. Okay, so with that we're pretty much good to go. We should see a sphere right where the mouse is at all times because what's gonna happen is it's going to hit the ground plane here, okay? So if I were to turn on my gizmos flag right here, you'll be able to see it in the scene of you as well, but to see it in the game view we need to turn on the gizmos button. So I'm gonna hit play and we actually haven't assigned the camera to the input, so that's why we're not getting anything. And also our tank is currently using gravity which is why it's falling down. We need to assign a collision mesh to it, but to get started let's go and drag and drop the camera into our tank inputs there and take a look again. All right, so now you can see that the little red sphere is actually following our mouse, okay? So that is the start to making this all work. All right, so let's finish up our input script by going and just putting in the vertical and horizontal values, all right? So we're gonna do the same process here. What I'm gonna do is I'm going to create a private float value and we're gonna call this our forward input, all right? We're going to create a public property for it. All right, we'll call this the forward input like so and we'll just do a get and return that forward input, the private variable. All right, so let's just copy this. Now we've seen that a few times there. All right, and there is a shortcut for all that but I'm gonna save that for a little bit. All right, so we're gonna call this the rotation input and I always just capitalize the property name just so I know that it is associated with the private variable or which variable it's associated with, all right? And I want to copy that and then paste that down like so and there we go. All right, and these guys are easy. So after we do the raycast here, what I can do is I can say that the forward input, all right, the private variable is equal to input.getAxis and by default in Unity, the W and S keys are set up to the vertical and that'll be our forward inputs and our rotation input is equal to our input.getAxis horizontal like so and with that we've got all of our inputs all set up and we've got enough information now to place our reticle. So I'm gonna close out the video there. We went on a little long but nothing too crazy. Let me know if you guys have any questions regarding properties or virtual methods and I'll be more than happy to answer them, okay? Thanks so much.