# First-Person Setup

This page walks through a complete first-person setup where the camera drives the character's body pose, typically used for full-body player avatars. 

If you have not yet installed FocalRig, created a Control Rig with an imported hierarchy, and connected it to an Animation Blueprint, see [Quick Start](/?id=quick-start).

## 1. Set Up the Camera Bone

The camera component in your character or actor blueprint should be attached to a dedicated bone (typically under `head`) that is placed between the eyes. The Control Rig contorls that bone, and the camera follows because it is attached to it. This way the camera stays stable as if it were attached to the capsule, but with procedural bob, sway, smoothing, recoil, etc produced by control rig.

The [First Person View Quick Setup](first-person-view.md?id=quick-setup) looks under `head` for a bone whose name contains `pov`, `camera`, `view`, or `eyes`, so it's most convenient to use a bone like that: you won't need to fill it in manually when you place the First Person View node.

### A. You already have a camera/pov bone

If your skeleton already has such a bone, simply attach the camera component to it in the actor blueprint. The First Person View node will control it directly.

### B. You have no camera/pov bone and cannot edit the source skeletal mesh

1. Open the Skeleton asset (e.g., SK_Mannequin)
2. In the skeleton tree, right-click the `head` bone, choose `Add Virtual Bone`, pick `head` as the target, and rename the new Virtual Bone to something like `VB camera_attach`.
3. Attach the camera component to that Virtual Bone in the actor blueprint.
4. Re-import the hierarchy into the Control Rig like in [Quick Start](/?id=quick-start) so that the new Virtual Bone shows up in the Rig Hierarchy.
5. In the Control Rig, under the `head` bone add a `pov` bone and move it around until it's between the eyes. Rotate it so it's red (X) axis points forward and its Z (blue) axis points up.

The First Person View node will control the `pov` bone in the Control Rig directly. However, since this bone only exists in the Control Rig, we'll copy its transform to the Virtual Bone that the camera is attached to.

### C. You have no camera/pov bone and can edit the source skeletal mesh

Add a `pov` bone under `head` in your DCC package (e.g., Maya or Blender), give it one of those recognized camera-style names, re-import the skeletal mesh, and attach the camera component to that bone in the actor blueprint. Similarly to A, the First Person View node will control this bone directly.

## 2. Add a Camera Control in the Control Rig

1. In the Control Rig, <span class="fr-term" tabindex="0" data-tooltip-key="add-control">add a control</span> named `camera_ctrl`.
<br>![camera_ctrl in Rig Hierarchy](_media/camera-ctrl-in-rig-hierarchy.png ':size=400px')
2. Set its "Shape" to "Wedge_Solid" and set its Initial transform to roughly where the character's point of view is in the idle pose and with the wedge pointing forward from the character's head.
<br>![camera_ctrl details](_media/camera-ctrl-details.png ':size=400px')
3. Drag the control into the graph to make a "Get Transform - Control" node, then connect it to a "From World" node. 
<br>![Get Control reading camera_ctrl](_media/camera-ctrl-get-global.png ':size=400px')

## 3. Add a GetFirstPersonCameraTransform function in the Animation Blueprint

1. In the Animation Blueprint, make a function named `GetFirstPersonCameraTransform`.
2. Mark it as pure and const, and give it a transform return value.
3. Inside the function, call `Try Get Pawn Owner`, pass it into [Get Pawn View Transform](get-pawn-view-transform.md), and return the result.

![GetFirstPersonCameraTransform function](_media/first-person-get-first-person-camera-transform-function.png ':size=1200px')

?> The return value must be called `ReturnValue` or <span class="fr-term" tabindex="0" data-tooltip-key="property-access">Property Access</span> won't work.

4. In the Anim Graph, connect `GetFirstPersonCameraTransform` to the Control Rig node's `Camera Ctrl` pin through <span class="fr-term" tabindex="0" data-tooltip-key="property-access">Property Access</span>.

![GetFirstPersonCameraTransform function called via Property Access](_media/first-person-anim-graph-property-access.png ':size=400px')

?> If the pin is missing, select the Control Rig node and enable that pin in the "Input" category.<br> If the pin is missing in the "Input" category, cut and paste the Control Rig node to make the control show up as a pin.

## 4. Set a Preview Pose

Open the Control Rig. In the "Preview Settings" tab set "Preview Controller" to "Use Specific Animation" and select an aiming forward pose or loop.
This helps [Quick Setups](quick-setups.md) detect bone orientations correctly. [Aim Weapon](aim-weapon.md) snaps the muzzle's local forward axis to the local ±X/±Y/±Z axis closest to the shoulder-to-muzzle direction in this pose, so preview the weapon pointed forward.

![Set Preview Animation in Control Rig Preview Settings](_media/controlrig-set-preview-animation.png ':size=400px')

?> You should pick a non-additive animation for the preview to work correctly. If you want to use the forward pose of an aim offset asset, duplicate that animation sequence and disable additive in the duplicate, then use the duplicate for the preview.

## 5. Build the Control Rig

![First-person Control Rig](_media/first-person-full-setup.png)

### 5.1. Look Setup

1. Feed `camera_ctrl` through `From World` into [First Person Camera Control](first-person-camera-control.md).
2. Connect First Person Camera Control's `Output Camera Transform` to [First Person Aim Target](first-person-aim-target.md)'s `Camera Transform`.
3. Connect First Person Camera Control's `Output Camera Transform` to [First Person View](first-person-view.md)'s `Desired Camera Transform`.
    - If you want visible camera recoil when you shoot, insert [Apply Spray To Camera](apply-spray-to-camera.md) between them.
    - If the camera bone you chose [above](first-person-setup.md?id=1-set-up-the-camera-bone) is a Virtual Bone, add `Set Transform` after First Person View and copy its `Final Camera Transform` to that Virtual Bone.

### 5.2. Aim Setup

1. Connect [First Person Aim Target](first-person-aim-target.md)'s `Aim Target` to [Aim Weapon](aim-weapon.md)'s `Target`.
2. If you want the weapon to follow burst spray, insert [Apply Spray To Target](apply-spray-to-target.md) before Aim Weapon, as shown above.
3. If Aim Weapon's [Quick Setup](aim-weapon.md?id=quick-setup) does not detect a good muzzle element, follow [Creating a Muzzle Element](aim-weapon.md?id=creating-a-muzzle-element).

### 5.3. Dynamic Settings

1. If you want to dynamically switch between aiming and not aiming, make a public boolean variable named `IsAiming` and connect it to the Aim Weapon's `Weight` through [Smooth Toggle](smooth-toggle.md).
2. If you want to use [Aim Down Sights](aim-weapon.md?id=aim-down-sights), make a public boolean variable named `IsAimingDownSights` and connect it to Aim Weapon's `Aim Down Sights > Weight` through Smooth Toggle.
3. If you want to use [Weapon Kick](aim-weapon.md?id=kick), make a public time variable named `TimeOfLastShot` and connect it to Aim Weapon's `Kick > Time Of Last Shot`.
4. If you want to use [Aim Lock](aim-weapon.md?id=aim-lock-weight), read a curve that spikes during a shooting animation (e.g., "Recoil") and connect it to Aim Weapon's `Aim Lock Weight`.
5. If you want to use [Spray](spray.md), make a public integer variable named `ShotsFiredInBurst` and connect it to `Spray > Shots Fired In Burst`. That value should come from your gameplay logic and represents how many shots have been fired so far in the current burst.

In the Animation Blueprint, the public variables you created will show up as pins. Connect them through <span class="fr-term" tabindex="0" data-tooltip-key="property-access">Property Access</span> from the gameplay state of your character:

![First-person Control Rig inputs in Anim Graph](_media/first-person-control-rig-in-abp.png ':size=500px')

If any pins are missing, make sure the variables are public and then select the Control Rig node and enable them in the "Input" category.

### 5.4. Optional: Aim Eyes

If you also want eye aiming, add [Aim Eyes](aim-eyes.md) after the nodes above and connect the same target used by Aim Weapon to it.
