Embarking on your Unity journey and eager to create a captivating first-person perspective? You've come to the right place. Unity, the industry-leading game engine, offers immense possibilities, and mastering its first-person camera is a must for any developer aiming to create immersive experiences. Let's dive into this comprehensive tutorial, designed to optimize your learning process and boost your Unity skills.

Before we delve into the nitty-gritty, ensure you have a solid understanding of Unity's interface and basic concepts. If you're new to the engine, consider exploring Unity's official tutorials or our beginner-friendly guides to get a firm footing.

Setting Up Your First-Person Camera
The first step in creating a first-person perspective is to set up your camera. Unity provides a prefab called 'First Person Character Controller' that includes a first-person camera. Let's use this as our starting point.

To import the prefab, navigate to Unity's menu: Assets > Import Package > Personal > FPCharacter. Once imported, you can find the prefab in your Project window. Drag and drop it onto your scene hierarchy to instantiate it.
Camera Follow & Look At Scripts

Now that you have the first-person camera in your scene, let's understand the two scripts that govern its behavior: 'First Person Controller' and 'FPC Camera'. The 'First Person Controller' script takes care of character movement, while the 'FPC Camera' script manages the camera's perspective.
The 'FPC Camera' script uses the 'Transform' component to follow and look at the player. It creates a smooth first-person effect by keeping the camera relative to the player's position and rotation. You can explore and modify these scripts in the Inspector window to adjust camera behavior.
Customizing Camera FOV & Clipping Plane
![[Unity Tutorial] First Person Controller: Spherical Worlds](https://i.pinimg.com/originals/0a/b2/ce/0ab2ce1aaaa7e7cf1aa01063d317b429.jpg)
One of the first adjustments you'll want to make is tweaking the camera's field of view (FOV) and clipping plane. The FOV determines the player's peripheral vision, while the clipping plane dictates the closest distance at which objects become visible.
You can adjust these settings in the 'FPC Camera' script. For instance, a FOV of 90 degrees provides a broader peripheral view, ideal for first-person games. The clipping plane value, usually set between 0.1 and 1, prevents the camera from displaying too close objects, enhancing performance and visual aesthetics.
Creating a Player-Moving Script

To control your player's movement, you'll need to create a script. Unity's 'Input' system provides a straightforward way to capture user input for movement. Let's create a simple script for moving the player forward, backward, left, and right.
Create a new C# script and name it 'PlayerMovement'. Double-click it to open it in your code editor. We'll create a script that uses the 'Input' system and the player's transform to move the character:





![[Unity 4] Seeing arms / legs in First Person View](https://i.pinimg.com/originals/3d/c0/49/3dc049e2308defd06a8d94fd429a98da.jpg)














```csharp using UnityEngine; public class PlayerMovement : MonoBehaviour { public float speed = 5.0f; // Adjust the speed as needed. void Update() { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); Vector3 direction = new Vector3(horizontal, 0, vertical).normalized; transform.Translate(direction * speed * Time.deltaTime); } } ```
Attaching the PlayerMovement Script
attach the 'PlayerMovement' script to the 'MainCamera' object in your hierarchy. This will allow the player's movement to affect the camera's position, creating a true first-person experience.
Now, you can press the W, A, S, and D keys to move your player (and camera) respectively forward, left, backward, and right in your Unity scene. You can further customize this script to add features like running, jumping, or other character behaviors.
Congratulations! You've successfully created a first-person camera and player movement in Unity. This is just the beginning of your Unity adventure. Continuously explore and experiment with other Unity features to create stunning, immersive games. Happy coding!