# Mechs

### Create Mech

#### Set Up Character Controller

1. Create a new game object and add a **Vehicle** component
2. Drag your mech mesh/armature onto the game object as a child
3. Add a **Rigidbody Character Controller** component
4. Add a **Gimballed Vehicle Controller** to the mech's root transform

#### Set Up Torso Joint

1. Create a new game object as a child of the mech and call it 'Torso Gimbal'
2. Add a **Gimbal Controller** component to it and drag it into the *Gimbal Controller* field in the inspector of the **Gimballed Vehicle Controller** component you added above
3. Add a new game object as a child of the Torso Gimbal and call it 'Horizontal Pivot'
4. Add a new game object as a child of the Horizontal Pivot and call it 'Vertical Pivot'
5. Open the inspector of the **Gimbal Controller** and set the *Horizontal Pivot* in the inspector to the Horizontal Pivot object you created, and the *Vertical Pivot* to the Vertical Pivot object you created

### Setting Up The Player

1. Create a new game object and call it 'Player'
2. Add a **Game Agent** component and make sure the *Is Player* checkbox is checked
3. Add a new game object as a child and add a **MCKPlayerInput\_InputSystem\_MechControls** component to it
4. Open the inspector of the **Game Agent** component and drag the mech you created above into the *Starting Vehicle* field

Now, when you play the scene, you can control the mech, but there are no animations, and the torso will not follow the mouse.

### Animating The Mech

#### Torso Control

To set up the mouse control of the torso:

1. Open the inspector of the **Gimballed Vehicle Controller** component on the mech
2. Add an element to the *Followers* list
3. Set the *Follower* to whatever gameobject or bone controls the torso's rotation, and set the *Target* to the Vertical Pivot game object you created above.

Now, the torso will follow the joint as it is controlled by the mouse.

#### Character Animations

1. Add a **Rigidbody Character Animations** component to the mech
2. Automatically, entries should be created for the Parameter Receivers in the inspector, with references to the **Animator** on your mech mesh/armature

#### Animator Override Controller

To make it easier to utilise the setup provided in the kit rather than having to build your own animator controller from scratch, use an animator override controller.

1. Create a new **Animator Override Controller** in the Project tab by *right clicking > Create > Animator Override Controller*
2. In the inspector, set the *Controller* to the **MechController\_Titan** animator controller provided in the kit
3. For each of the animations that appear in the list, set the *Override* to whatever animation you want to use to replace it
4. Drag the Animator Override Controller you just created into the *Controller* field on the **Animator** on your mech mesh/armature
5. On the **Animator**, make sure *Apply Root Motion* is unchecked

Now, when you play the scene, you should have full movement, torso control, and animations.

### Independent Legs

To make the legs independently controlled (like MechWarrior) check the Independent Legs checkbox in the inspector of the **MCKPlayerInput\_InputSystem\_MechControls** component on the player.
