CharacterIKController
A class in Root.Township, the global namespace.
Runs a player character's IK (body following head and hands) and lets it be turned off, for example for out-of-body moments, with the change synced to other players. On every player character.
- Listed in Global namespace: C to D
- Inherits or implements
NetworkEntityBehaviour,IInitializeAsLocalPlayer
Constructors
| Member | What it is |
|---|---|
CharacterIKController() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
14 private and internal fields
| Member | What it is |
|---|---|
private CharacterComponentControllerCollection characterComponentControllers | The IK component controllers updated by FixedUpdateIK and UpdateIK. |
private Transform headTarget | Transform the head IK follows. |
private Transform headTargetLocalParent | Parent for the head target when this is the local player. |
private Transform headTargetRemoteParent | Parent for the head target when this is a remote player. |
private SerializableTransform headTargetTransform | Saved local transform restored on the head target when IK is enabled. |
private bool isAutomaticallyFillingTargetTransform | Inspector button flag that triggers AutomaticallyFillTargetTransforms. |
private HandTargetHandler leftHandTarget | Left hand IK target handler. |
private Transform leftHandTargetParent | Parent restored on the left hand target when IK is enabled. |
private SerializableTransform leftHandTargetTransform | Saved local transform restored on the left hand target when IK is enabled. |
private static Logger logger | NLog logger for this class. |
private PlayerCharacter playerCharacter | The player character this controller drives. |
private HandTargetHandler rightHandTarget | Right hand IK target handler. |
private Transform rightHandTargetParent | Parent restored on the right hand target when IK is enabled. |
private SerializableTransform rightHandTargetTransform | Saved local transform restored on the right hand target when IK is enabled. |
Properties
| Member | What it is |
|---|---|
bool IsIKControlActive { get; private set; } | True while IK drives the hand and head targets. |
1 private and internal property
Events
| Member | What it is |
|---|---|
event UpdateHandler IKUpdatesFinished | Raised after the body IK has updated. Held items such as keys use it to reposition. |
event UpdateHandler PreIKUpdates | Raised before the IK components update. Bow strings and ropes use it. |
event UpdateHandler PreRenderCallback | Raised after IKUpdatesFinished, once IK is done for the frame. |
Methods
| Member | What it is |
|---|---|
void DisableIKControl(IKControllSettings settings) | Detaches the hand and head targets from IK, optionally disabling IK fully and showing ghost hands. Local players sync it to others. |
void DisableIKControl(out Transform leftHandTarget, out Transform rightHandTarget, IKControllSettings settings) | Detaches the hand and head targets from IK, optionally disabling IK fully and showing ghost hands. Local players sync it to others. |
void EnableIKControl(IKControllSettings settings) | Puts the hand and head targets back under IK. Local players sync it to others. Logs an error if already active. |
void FixedUpdateIK() | Runs the IK components' fixed update while the player is alive (and has input focus in the editor or on Quest). |
override void Initialize() | Registers the handler for IK enable and disable messages. The server relays them to other players. |
void OnBodyIKFinished() | Raises IKUpdatesFinished then PreRenderCallback, logging any handler errors. |
void OnPreIKUpdate() | Raises PreIKUpdates, logging any handler errors. |
void SetConstantGhostHandVisibility(bool isAlwaysVisible) | Forces both ghost hands fully visible, or hands them back to their normal fading. |
void UpdateIK() | Runs the IK components' update while the player is alive (and has input focus in the editor or on Quest). |
5 private and internal methods
| Member | What it is |
|---|---|
private void AutomaticallyFillTargetTransforms() | Editor: saves the current hand and head target parents and transforms so IK can be restored later. |
private void Awake() | Marks IK control active and hooks the component controllers' pre and post update events. |
private void IInitializeAsLocalPlayer.InitializeAsLocalPlayer(PlayerController player) | Marks the component controllers as local. |
private void OnValidate() | Editor: runs AutomaticallyFillTargetTransforms when its inspector button is pressed. |
private void SyncWithRemote(IPlayer player, Stream stream) | Handles an IK controller message: enables or disables IK to match, and the server relays it to the other players in range. |
Used in
Members of other types that take, return or hold a CharacterIKController: