class MAGES::CharacterController::HeadController

Overview

HeadController class that handles everything regarding the head: Blinking, head Gaze, Eye Movement. More…

class HeadController
{
public:
    // enums

    enum Axis;
    enum LookAround;

    // classes

    class EyePreset;
    class LookAtObjectData;

    // properties

    Vector3 LookAtObjectPosition;
    bool IsLookingAround;
    Transform LeftEye;
    Transform RightEye;
    string BlinkBlendShapeName;
    List<EyePreset> EyePresetsList;
    bool AnimationRiggingAdded;

    // methods

    void LoadPreset(EyePreset preset);
    void LoadPreset(EyePreset preset, float duration, float percentange = 1f);
    SkinnedMeshRenderer GetHeadRenderer();
    void SetupHeadBone();
    void SetupRigGaze();
    void ExecuteLookIdle();
    void StopLookIdle();
    void ResetHead(float duration = 1f);

    void LookAt(
        Vector3 position,
        float lookForSeconds = 0f,
        float lookInSeconds = 0.2f
    );

    void LookAt(GameObject lookAtGameObject, float speed = 1f);
    void Init(GameObject gameObject, bool onStart = false);
    void ExecuteEyeIdle();
};

Detailed Documentation

HeadController class that handles everything regarding the head: Blinking, head Gaze, Eye Movement.

Properties

Vector3 LookAtObjectPosition

Gets the position the character is currently looking at.

bool IsLookingAround

Gets a value indicating whether the character is looking around.

Transform LeftEye

Gets or sets the left eye of the character.

Transform RightEye

Gets or sets the right eye of the character.

string BlinkBlendShapeName

Gets or sets the blink blend shape name.

List<EyePreset> EyePresetsList

Gets the Eye preset list, used to set the eye states.

bool AnimationRiggingAdded

Gets a value indicating whether animation rigging has been added or not.

Methods

void LoadPreset(EyePreset preset)

Instanly loads an eye preset.

Parameters:

preset

The preset that we are loading (i.e the rotations and the blink of the eyes

void LoadPreset(EyePreset preset, float duration, float percentange = 1f)

Smoothly load a preset in seconds.

Parameters:

preset

The preset that we are loading (i.e the rotations and the blink of the eyes.

duration

The duration of the load, meaning how long the interpolation of the rotation is going to take.

percentange

The percentange of the load.

SkinnedMeshRenderer GetHeadRenderer()

Gets the head renderer.

Returns:

headRenderer.

void SetupHeadBone()

Sets up the head constraint.

void SetupRigGaze()

Sets the rig up for the user.

void ExecuteLookIdle()

Executes the idle look around.

void StopLookIdle()

Stops the look idle around.

void ResetHead(float duration = 1f)

Resets the head.

Parameters:

duration

The duration the function will need in order to reset the head.

void LookAt(
    Vector3 position,
    float lookForSeconds = 0f,
    float lookInSeconds = 0.2f
)

Look at function to look at a specific position for x time. If 0 then it looks at that point forever.

Parameters:

position

The position of the gameObject you want to look at.

lookForSeconds

Look for x amount of seconds. If 0 then it wont stop looking.

lookInSeconds

Smoothly rotate the head to look at the target in x seconds

void LookAt(GameObject lookAtGameObject, float speed = 1f)

Look at function that follows a gameObject.

Parameters:

lookAtGameObject

The gameObject the head follows.

speed

The speed.

void Init(GameObject gameObject, bool onStart = false)

Initializes the head functions, like eye movement, blinking and look around.

Parameters:

gameObject

The gameObject.

onStart

The onStart bool.

void ExecuteEyeIdle()

Responsible for executing the eye movements and blinks.