Setting up a Player prefab for First Person

Assuming you've already created a Player prefab following the previous tutorials, let's build upon it to make it ready for a First Person game.

Start by going to the Settings Manager and changing your Movement method to First Person if you haven't already. The Required inputs list beneath it will change to reflect this.

First Person mode requires three additional input axes: CursorHorizontal, CursorVertical, and ToggleCursor. You can add these axes from the Input Manager, found in the top toolbar under Edit -> Project Settings -> Input

To move forward, backward, and strafe with the keyboard, set up the Horizontal and Vertical axes as follows:

To look around the First Person view with a mouse, set up the CursorHorizontal and CursorVertical axes as follows:

To control the view with the keyboard numpad, set them up like this instead:

To control the view with an Xbox 360 controller, set them up like this instead:

Finally, define the ToggleCursor axis:

Now let's add the First Person camera to our Player prefab. With our Player prefab in our scene, add a new Camera object by selecting GameObject -> Camera in the top toolbar. In the new object's Inspector, disable the Camera component, delete the Flare Layer, GUILayer, and Audio Listener components, and tag it as Untagged (or just not "MainCamera").

Then add the First Person Camera component. You can tweak the values within it to achieve your desired behaviour.

Then position the camera such that it takes the first-person view of the Player prefab.

Then drop the camera onto the Player prefab in the Hierarchy, so that it becomes a child of the Player.

Update the Player prefab by clicking "Apply" at the top of it's Inspector, then remove it from the scene. The prefab is now ready for First-Person control.

Adventure Creator and this website are copyright Chris Burton, ICEBOX Studios

Go to top
Do NOT follow this link or you will be banned from the site!