GAMEPAD/KEYBOARD FIRST PERSON PLAYER
This tutorial will show you how to create a first-person player in Unity that works with controllers and keyboards.
Note: A small section of the code is an improved version of Brackey's first-person player tutorial that has been modified by simplifying multiple scripts into one, and making it compatible with controllers. You can watch his video here: https://www.youtube.com/watch?v=_QajrabyTJc
First off, create a new 3D project in Unity, and name it whatever you would like. Create a new 3D GameObject plane, and set the coordinates to (0, 0, 0). Next, make a new capsule, name it "Player", and set the position to (0, 2, 0) and the scale to (1.04, 1.3, 1.04). Then, drag the Main Camera GameObject into the Player, making it a child of the player. This makes the main camera go wherever the player goes. Next, set the main camera coordinates to (0, 0.45, 0). Then, go into the Player GameObject and click "Add Component", and add a Rigidbody. In the Rigidbody component, go to Constraints, and select all of them, except for the Y Position. Press control S to save your project.
For the next part, which is making the project able to use input from controllers, we could either spend a few hours creating a custom one using a lot of scripting and looking documentation up, or we could import a ready-to-use free one from the Unity Asset Store. To get it, you can go to the Asset Store window in Unity and type in "Gamepad Input" in the search bar. Scroll down until you see the free one created by Richard Pieterse. From there you can click Add to My Assets, Download, and then after it finishes downloading, click import. Once it finishes importing, you must open the file folder outside of Unity where your game is. Go to assets, GamepadInput, and right-click on the InputManager ZIP file, and then click on extract all. It will ask you to select a location to unzip the file to, so select the ProjectSettings folder. It will then tell you there is already an InputManager in the file, and you must click "Replace the file in the destination". Once it copies over and it finishes loading, you can close out of the file folder, and you must close out of Unity and restart your project for the changes to be in place. Once you open the project up again, go the bar up top, again click on Edit > Project Settings > Input. From there, click on Axes. You will see a number next to the field "Size". Increase that number by two. Scroll down, and you will see 2-3 options titled "Cancel". If you see 3, decrease the Size field at the top by 1. Now, set the name of the first Cancel to Mouse X. Now, set the name of the second Cancel to Mouse Y.
Next, in the Player, click "Add Component" again, type in "PlayerMovement", click on Create New Script, and then on Create and Add. Once you can see the script has loaded in, go to the Project window, and double click on the PlayerMovement script to open it up in a C# script editor.
For the next part, which is coding the player, you can either copy and paste the script below, type it out by hand, or watch the video above (not currently out yet) to make it. (Because the website hosting service doesn't support C# files, it is a PDF, where you can still copy and paste the text)
Now that you have the code, you can go back into Unity, and go to the Player GameObject. From there, you can drag the Main Camera into the PlayerCam spot in the script, and the Rigidbody component into the PlayerRB spot. Now, you can hit the play button at the top to view the final results. Currently, to switch between controllers and keyboards you have to press C, but you could use "controlType=!controlType" to make a settings menu, a different key, or something else.