> For the complete documentation index, see [llms.txt](https://oscar-gracian.gitbook.io/easy-character-movement-2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oscar-gracian.gitbook.io/easy-character-movement-2/user-manual/general/getting-started.md).

# Getting Started

This document describes the steps for creating and controlling a character.

## Creating a Character

* Right-click on the hierarchy window to open the creation dialog and select the **Character** option from the **ECM2** category.

&#x20;      ![](/files/0bIF3ZMLgVadkpId4iuR)

* &#x20;It will create an empty character (no visual representation) named **Character.**

<figure><img src="/files/DoB2meOJls1WNOZGGgrb" alt=""><figcaption><p>Newly created Character</p></figcaption></figure>

{% hint style="success" %}
Make sure its origin is set to (0, 0, 0) as this will save you troubles when parenting your model.
{% endhint %}

* Parent your model to this newly `Character` `GameObject`. For this example, we'll use the included **ECM2\_Capsule** model.

<figure><img src="/files/gZLciA8PsW443hMBMTSP" alt=""><figcaption><p>Character's model</p></figcaption></figure>

* In the `CharacterMovement` component, adjust its **radius** and **height** values (this will automatically configure your character’s capsule collider) to better fit your character’s model.

<figure><img src="/files/jVT8sX0PTIQLH4FJY8fu" alt=""><figcaption><p>CharacterMovement component</p></figcaption></figure>

## Controlling a Character

In the previous section, we discussed the steps to create and configure our `Character`. However, at this point, we are unable to move or control it. We will address and resolve this creating a new `CharacterInput` script.

A `Character` encompasses a collection of methods designed to facilitate action execution. For instance,  its `SetMovementDirection` method is employed to prompt the character to move in a specified direction (in world space).&#x20;

Similarly, the `Jump` method initiates a jump, while the `StopJumping` method halts the ongoing jump—particularly crucial when a variable jump height is in use.

Likewise, the `Crouch` method is utilized to initiate the character's crouching action, and the `UnCrouch` method is employed to cease the crouching state.

The complete script is shown below:

```csharp
using UnityEngine;
using ECM2;

namespace ECM2.Examples
{
    public class CharacterInput : MonoBehaviour
    {
        // The controlled Character
        
        private Character _character;

        private void Awake()
        {
            // Cache controlled character
            
            _character = GetComponent<Character>();
        }

        private void Update()
        {
            // Poll movement input
            
            Vector2 inputMove = new Vector2()
            {
                x = Input.GetAxisRaw("Horizontal"),
                y = Input.GetAxisRaw("Vertical")
            };
            
            // Compose a movement direction vector in world space
            
            Vector3 movementDirection =  Vector3.zero;

            movementDirection += Vector3.right * inputMove.x;
            movementDirection += Vector3.forward * inputMove.y;
            
            // If character has a camera assigned,
            // make movement direction relative to this camera view direction
            
            if (_character.camera)
            {               
                movementDirection 
                    = movementDirection.relativeTo(_character.cameraTransform);
            }
            
            // Set character's movement direction vector

            _character.SetMovementDirection(movementDirection);
            
            // Crouch input
            
            if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.C))
                _character.Crouch();
            else if (Input.GetKeyUp(KeyCode.LeftControl) || Input.GetKeyUp(KeyCode.C))
                _character.UnCrouch();
            
            // Jump input
            
            if (Input.GetButtonDown("Jump"))
                _character.Jump();
            else if (Input.GetButtonUp("Jump"))
                _character.StopJumping();
        }
    }
}
```

Finally, add the newly created `CharacterInput`  script to your  **Character** GameObject. You should be able to **move**, **jump** and **crouch**!

{% hint style="warning" %}
**Crouching** and **UnCrouching** only modify the character's capsule collider.
{% endhint %}
