Skip to content

Character API

This section covers the inners of the Character component and which tools are exposed for programmers to use.

Locomotion

To move a character to a certain location, you'll need to access the IMotion unit, which handles the response to locomotion signals. To know more about Kernel Units, visit the Character Controller page.

There are 3 movement types that a character can perform:

  • Move to a position: Which is done using the MoveToLocation(...) method.
  • Move towards a direction: Which is done executing the MoveToDirection(...) method.
  • Start/Stop following a target: Which is done using the StartFollowingTarget(...) and StopFollowingTarget(...).

For example, to force a character to move to a target's transform position, the following snipped should be used:

Location location = new Location(target.position);
character.Motion.MoveToLocation(location, 0f, null);

Ragdoll

As long as the character has a Skeleton, a ragdoll state can be triggered. To make a character enter the ragdoll state use the character.Ragdoll.StartRagdoll() method. To recover from a ragdoll state, execute the character.Ragdoll.StartRecover() method.

Ragdoll and Death

We recommend setting the character as dead before entering the ragdoll state. Otherwise the ragdoll animation might want to perform actions only available to non-Ragdoll characters (such as running, shooting, jumping, ...).

Animations

To play an animation Gesture you can access the Gestures property and trigger the CrossFade(...) method, which handles creating a new layer (if necessary) on top of Unity's Mecanim and play the desired animation.

To enter or exit an animation State you can access the SetState(...) and Stop(...) methods from the State property.

Note that all animation methods are async. This means that your code can yield until the animation has finished executing. For example, to play a gesture animation and print a console message right after the animation has finished you can use:

Debug.Log("Start playing a new animation gesture")
await character.Gestures.CrossFade(myAnimationClip, ...);
Debug.Log("The previous animation has finished")

Change Model

To change a character model, call the ChangeModel(...) method. Its signature contains 2 parameters:

  • A prefab object reference, which should be the FBX model
  • A configuration struct of type ChangeOptions

This last optional parameter allows to define the new model's footstep sounds, its skeleton's bounding volumes as well as a new animator controller and an offset. For example, to change the player's model without any optional parameters:

GameObject instance = character.ChangeModel(prefab, default);

Busy

Accessed from the Busy property, it allows to query whether a specific limb of the character is being used or not. This allows other systems to determine whether an action can be performed or not.

Busy and Available limbs

For example, if a character has both of its arms set as unavailable, trying to execute an action that involves the hands won't be possible, such as grabbing a ladder.

The follow properties can be queried and inform of the availability state of the limb or group of limbs:

IsArmLeftBusy : boolean
IsArmRightBusy : boolean

IsLegLeftBusy : boolean
IsLegRightBusy : boolean

AreArmsBusy : boolean
AreLegsBusy : boolean

IsBusy : boolean

Additionally, limbs can be marked as busy or make them available using the MakeLimbXXX() method, where XXX is the limb of the body. For example, to set the Left Leg as busy, call the MakeLegLeftBusy() method.

All available methods

For more information about all the available methods on the Busy system, check the script under Plugins/GameCreator/Packages/Core/Runtime/Characters/Busy.

Back to top