Skip to main content

Character Controllers

Character Controllers is a tool that allows developers to quickly add player movement and enable player-following cameras for first person and third person point of views.

This package is created by Unity and is named Starter Assets. It is installed by default in the Genies Dev Kit and is ready to use.

tip

Read Unity's Starter Assets documentation for more information.

Character Controller Assets

The Character Controller components and example scenes can be found in the Project window under the Assets > GeniesSdk > StarterAssets folder.

Starter Assets

Example Scenes

There are two example scenes that can be found in the Assets > GeniesSdk > StarterAssets > Genies folder.

Example Scenes

Genies Third Person Example

The Genies Third Person Example scene loads the Avatar and has mobile-friendly UI to jump, move the player, and rotate the camera.

Third Person Example

note

The grey rectangle UI designates where the player can drag their finger to move the player and everything outside of the rectangle will rotate the camera.

Genies First Person Example

The Genies First Person Example scene has the same mobile-friendly UI for player movement and camera rotation; however, it does not load the Avatar and instead has the camera positioned at the player's head.

First Person Scene

Adding Character Controller to an Existing Project

Add Cinemachine Cameras

Start by adding a Cinemachine Brain component to the Main Camera.

For first person games, add the PlayerFollowCamera prefab found in the Assets > GeniesSdk > StarterAssets > FirstPersonController > Prefabs folder.

For third person games, add the PlayerFollowCamera prefab found in the Assets > GeniesSdk > ThirdPersonController > Prefabs folder.

caution

The PlayerFollowCamera prefab is a Cinemachine camera, so if the active camera in the scene does not have a Cinemachine Brain component, then the PlayerFollowCamera will not be able to override the camera. Read the Cinemachine page for more information.

Add a Character Controller Prefab

For first person games, add the PlayerCapsule prefab found in the Assets > GeniesSdk > StarterAssets > FirstPersonController > Prefabs folder.

For third person games, add the GeniesThirdPersonRig prefab found in the Assets > GeniesSdk > StarterAssets > Genies folder.

Reference the Camera Root

With those prefabs added to your scene, you can now set up the camera to follow the player.

In the Hierarchy, find the PlayerCameraRoot object which is a child of both types of character controllers. Then, select the PlayerFollowCamera object and open the Inspector window. Drag the PlayerCameraRoot object into the Follow property.

Player Follow Camera

TypeScript Usage

Package

The Character Controller API can be accessed from the Starter Assets library, like so:

import { FirstPersonController, ThirdPersonController } from "StarterAssets";

Example

Here is an example script to freeze the player for two seconds at the start of the game:

import { ThirdPersonController } from "StarterAssets";
import { MonoBehaviour, WaitForSeconds } from "UnityEngine";

export default class MyScript extends MonoBehaviour {

@SerializeField private thirdPerson: ThirdPersonController;

private playerSpeed = 3;

Start() {
this.thirdPerson.MoveSpeed = 0;
this.StartCoroutine(this.ResetPlayerSpeed());
}

*ResetPlayerSpeed() {
yield new WaitForSeconds(2);
this.thirdPerson.MoveSpeed = this.playerSpeed;
}
}