---
description: In this section we will add demo scripts.
---

# Controller setup

## Add Character and FPS Controllers

First, add the standard Character Controller:

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2FDz7adugCBttuygsHjdym%2Fimage.png?alt=media&#x26;token=86484eba-34f4-419c-b824-9d22788a1170" alt="" width="446"><figcaption><p>You can use similar values.</p></figcaption></figure>

Now we need to add a demo project script - FPSController. It handles all the gameplay actions in the project.

### Turn In Place

Once you've added the **FPSController**, set up the Turn In Place feature first:

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2FBwa5141ANUYSKxBzRb75%2Fimage.png?alt=media&#x26;token=529d5ab0-7d14-4e83-bb8c-b05d487b87ca" alt="" width="422"><figcaption><p>Turn in place settings.</p></figcaption></figure>

The **Turn Curve** must be in range \[0;1], for both value and time:

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2FezOCDrjFVInDiEonZCM9%2Fimage.png?alt=media&#x26;token=fa1dda3c-aafd-4e3b-aede-f9fb786738e4" alt="" width="328"><figcaption><p>Turn curve.</p></figcaption></figure>

This curve will be used to procedurally rotate the character when it's time to turn.

### Smooth Leaning

Now we need to adjust the **Smooth Leanin**g - a game mechanic, which allows to control the leaning amount with the mouse wheel:

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2F3kzRlvhM0oVFx3WQA06j%2Fimage.png?alt=media&#x26;token=1ba51123-54fe-41d7-8561-1f3470acb1d3" alt="" width="390"><figcaption><p>Smooth leaning settings.</p></figcaption></figure>

**Smooth Lean Step** defines the leaning sensitivity, and **Start Lean** defines the initial leaning amount in percents (1 means 100%, 0 means 0%).

### IK Animations/Poses

Now we need to set up the **IK Animation**:

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2Fn0Yjg1Q4KwfHkNgMivJ0%2Fimage.png?alt=media&#x26;token=bb1e53d1-b957-4404-ba63-ac4e3a820c11" alt="" width="389"><figcaption><p>IK Transition motions.</p></figcaption></figure>

**IK Animation** is a Scriptable Object, which is applied procedurally and used as a transitions motion for aiming, leaning, crouching and jumping events:

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2FHkr1sJFXesaGEOTrGIFO%2Fimage.png?alt=media&#x26;token=23115e04-195a-4cc0-bb07-221495cd5a38" alt="" width="317"><figcaption><p>IK Animation example.</p></figcaption></figure>

**Rot and Loc** are animation curves for each rotation/translation axis

**Blend Speed** defines how fast we want to blend the motion in.

**Play Rate** defines the speed of the motion.

**Scale** is a global multiplier for the motion, and it's computed randomly in range \[X;Y].

Another IK feature used in the FPS Animation Framework is **IK Poses**. Unlike IK Animations, which are fire-and-forget type of thing, the IK Poses are mean to be used for different animation states.&#x20;

For example, let's say we don't like our pose when sprinting. We can create a new **IK Pose** for this animation state, and simply blend it in when we start sprinting:

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2FRzzULzEoLge4McnRkgou%2Fimage.png?alt=media&#x26;token=a2d70a1c-427f-49ec-9806-0016c2d3151f" alt="" width="317"><figcaption><p>IK Pose example.</p></figcaption></figure>

**Pose** defines the additive offset for rotation/translation, and **Blend In/Out Speed** defines how fast we want to blend in/out.

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2FZkd9PA7ZeweDmAzClts4%2Fimage.png?alt=media&#x26;token=83041a7c-0117-4f38-a38d-f73bf8ba98ab" alt="" width="392"><figcaption><p>You can assign IK Poses in FPSController/Animation tab.</p></figcaption></figure>

### Controller Settings

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2FucQFnuQKGr49WK7w9fTm%2Fimage.png?alt=media&#x26;token=c1a4e0bb-2668-4c57-b115-1d2a2d2beade" alt="" width="367"><figcaption><p>Controller tab settings.</p></figcaption></figure>

Now let's set up the Controller tab.

**Time Scale** allows you to add a slow motion effect, if less than 1.

**Equip Delay** defines the timer length for the wepaon equip action. We don't rely on the animation events, instead we set a timer when we start equipping another weapon.

Assign **Main Camera**, **Camera Holder** and **First Person Camera** objects using the references from the [camera-setup](camera-setup "mention") step. (Edit: **First Person Camera** is the FPCameraSocket).

Finally we have a Movement Component reference, which we will deal with in the next chapter.

## Movement Component

All movement logic is handled in the **FPSMovement.cs** script. Add this component directly to your character and assign its reference in the **FPSController**/Controller tab.

Let's take at the inspector:

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2FbUOI322ce6Qj4iASqDS3%2Fimage.png?alt=media&#x26;token=1d00a38a-dae9-4540-99b5-d99273eec8b7" alt="" width="383"><figcaption><p>FPSMovement component.</p></figcaption></figure>

Use the **rootBone** GameObject in the skeleton hierarchy and assign it to the respective property.

**Movement Settings** is a Scriptable Object, which contains all the necessary settings for different movement states:

<figure><img src="https://3983499731-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxsGuM7QMKoTm8rnHX3cO%2Fuploads%2F0Nhbgas6ozBxchSFAo5a%2Fimage.png?alt=media&#x26;token=3d2414e2-5199-4234-9237-3baf05449a6d" alt="" width="380"><figcaption><p>You can find it in the Assets/Demo/DataAssets.</p></figcaption></figure>

**Idle, Prone, Crouching and others** contain a Velocity (defines the movement speed) and Velocity Smoothing (how responsive the state should be. If zero - no smoothing applied).

**Crouch Ratio** is a multiplier for the capsule height when crouching.

**Jump Height** defines how high we want to jump.

**Air Friction/Velocity** represent the responsiveness and movement speed when in air.

**Max Fall Velocity** will be used to clamp the gravity.

**Slide Curve** defines how sliding will be applied.

**Slide Dircetion Smoothing** defines the responsiveness when sliding.

**Slide Speed** defines the sliding velocity.

At this point we've completeted the character setup. We will learn how to set up a weapon from scratch in the next section.
