Skip to main content

PlayerCharacter

A class in Root.Township, Alta.Character.

The player's body in the world: the PlayerController used for normal play, with the character dummy, IK, belt and back docks, inventory and customization. Both sides; get it from player.PlayerCharacter.

Constructors​

MemberWhat it is
PlayerCharacter()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

24 private and internal fields
MemberWhat it is
private PickupDockGroup backDocksBacking field for BackDocks.
private PickupDockGroup beltDocksBacking field for BeltDocks.
private ColliderGroup bodyColliderGroupBacking field for BodyColliderGroup.
private BodyController bodyControllerBacking field for BodyController.
private Coroutine currentRotateCoroutine field for a rotation. Not used in this class.
private Coroutine currentScalingCoroutine field for scaling. Not used in this class.
private Coroutine currentTranslateCoroutine field for a move. Not used in this class.
private PlayerCustomizationHandler customizationHandlerBacking field for CustomizationHandler. Destroyed when the character is unlinked or destroyed.
private DockPositionController dockPositionControllerBacking field for DockPositionController.
private CharacterDummyPointer dummyPoints to the CharacterDummy (rig, animator, cosmetics) behind Dummy.
private Transform headFollowBacking field for HeadFollow.
private CharacterIKController ikControllerBacking field for IKController.
private bool isFadingOnMoveSerialized flag. Not read in this class.
private CharacterLocalityController localityControllerBacking field for LocalityController, which also supplies Head.
private float minimumDistanceForTrailSerialized distance for the teleport trail (5 by default). Not read in this class.
private float moveDurationBacking field for MoveDuration.
private Renderer nonBakedCharacterRendererEditor-only renderer that Bake destroys at build time.
private Transform nonBakedCharacterRendererPivotPivot for the non-baked renderer. Not used in this class.
private RigidbodyCollection rigidbodiesBacking field for Rigidbodies.
private float scaleVelocitySmoothing velocity for scaling. Not used in this class.
private PlayerSpecialEffectsController specialEffectsControllerBacking field for SpecialEffectsController.
private PooledObjectDefinition teleporterTrailPooled teleport trail effect. Not used in this class.
private LocomotionStyle teleportStyleBacking field for TeleportStyle.
private Vector3 translateVelocitySmoothing velocity for moving. Not used in this class.

Properties​

MemberWhat it is
PickupDockGroup BackDocks { get; }The dock group on the player's back.
PickupDockGroup BeltDocks { get; }The dock group on the player's belt.
Animator BodyAnimator { get; private set; }The character dummy's animator. Turned off during physics steps while IK runs.
ColliderGroup BodyColliderGroup { get; }The body's colliders. Downed and dead states switch them off; arrows ignore the shooter's own.
override BodyController BodyController { get; }The body controller that moves the body under the head and hands.
PlayerCustomizationHandler CustomizationHandler { get; }Applies the player's cosmetics to this body. Attached when the body links to a player.
DockPositionController DockPositionController { get; }Places belt docks to fit the body type.
CharacterDummy Dummy { get; }The character dummy (model, animator, fingertips, cosmetics packer).
override Transform Head { get; }The head transform from the locality controller.
override Transform HeadFollow { get; }Transform that follows the head.
override float HeadHeight { get; }Local height of the head, from the locality controller.
PlayerHealth Health { get; }The body's PlayerHealth.
CharacterIKController IKController { get; }The IK controller, updated every frame and physics step.
Inventory Inventory { get; private set; }The player's inventory helper, created in Awake.
CharacterLocalityController LocalityController { get; }Handles which parts show for the local player versus others (head and so on).
PlayerLocomotionController LocomotionController { get; }The PlayerLocomotionController moving this body.
float MoveDuration { get; }Serialized move duration (0.01 seconds by default); nothing else in this build reads it.
RigidbodyCollection Rigidbodies { get; }The body's rigidbodies.
PlayerSpecialEffectsController SpecialEffectsController { get; }Plays special effects on the body.
LocomotionStyle TeleportStyle { get; set; }Locomotion style for teleports. Settable; nothing else in this build reads it.
protected override SaveMode SaveMode { get; }Always SaveMode.Player: saved with the player save, not with a chunk.
1 private and internal property
MemberWhat it is
private FingerTipSettings IHasFingertips.FingerTips { get; }Fingertip settings, taken from the character dummy.

Events​

MemberWhat it is
event ScaleChangedHandler ScaleChangedDeclared for scale changes and listened to by the dock dropper, but nothing in this build raises it.

Methods​

MemberWhat it is
override void Bake(bool isSaving)Build time: removes the non-baked character renderer.
override void LoadFrom(PlayerSave save)Server: loads the body and hands from the player save. A player with no saved prefab data gets the default starting data.
override void OnConnected(Player player)When the owning player connects, sends them their last safe position if one is saved.
override void SaveTo(PlayerSave save)Writes the body's network prefab data (docks, held items and so on) into the player save.
override void UnlinkFromPlayer()Destroys the customization handler and stops listening for armed changes before the base unlink.
protected override void Awake()Sets up health, creates the Inventory, grabs the body animator and hooks dock placement to the body type once cosmetics are packed.
protected override void OnDestroy()Destroys the customization handler with the body.
6 private and internal methods
MemberWhat it is
private void OnArmedChanged(bool isArmed)Server: sets the Armed sense on the player's AI target when the player arms or disarms, so creatures can react.
private void OnEnable()Starts the UpdateIK coroutine.
private void OnLinkedToPlayer()Runs when linked to a player: marks it alive, sets up locality and first-person customization, and on the server watches the armed state.
private void SetupDocksBasedOnBodyType()Places the tool belt and pouch belt docks for the dummy's body type once its cosmetics finish packing.
private void Update()Re-enables the body animator and runs the IK update every frame, recovering the animator reference if it was destroyed.
private IEnumerator UpdateIK() (iterator)Coroutine that runs the fixed-step IK each physics step with the body animator turned off.

Used in​

Members of other types that take, return or hold a PlayerCharacter:

PlayerEffectController.player, PlayerEffectController.Player, Inventory.Inventory, PlayerText.player, Inventory.AddBackDocks, Inventory.AddBeltDocks, EquipmentCustomizationRoom.linkedPlayerCharacter, Chest.currentPlayer, IPlayer.PlayerCharacter, CombatShellAnimator.CombatShellAnimator, ShellAnimator.Character, ShellAnimator.ShellAnimator, StatEffectShellAnimator.StatEffectShellAnimator, PlayerStateBase.PlayerCharacter, LocalPlayerHeadRenderer.character, LocalPlayerHeadRenderer.Register, PlayerSwapMaterialFilter.playerMap, PlayerSwapMaterialFilter.toRemove, PlayerSwapMaterialFilter.PlayerOriginalMaterials.PlayerOriginalMaterials, EventOrb.playerCharacter, DownedStateDebuffManager.ApplyDebuffToPlayer, DownedStateDebuffManager.playerStatModifiers, DownedStateDebuffManager.RemoveDebuffsForPlayer, PlayerControllerPrefabs.vrPlayer, PlayerControllerPrefabs.VrPlayer, BowString.IgnoreCollisionBetweenArrowAndBow, BowString.PlayerAndBowColliders, CharacterIKController.playerCharacter, ClothManager.player, ClothManager.Player, Embeddable.IsRaycastedRigidbodyFromTheThrowingPlayer, ExtraArrowUpdater.interactingPlayer, GravityChanger.playerCharacter, GravityChanger.PlayerCharacter, Player.PlayerCharacter, PlayerDockDropper.player, PlayerEventsManager.character, PlayerEventsManager.OnCharacterAdded, PlayerLocomotionController.PlayerController, PlayerProgressionManager.RegisterStat, PlayerSpecialEffectsController.playerCharacter, ProgressionSettings.LevelUpEffect, RigidbodyGroup.player, RigidbodyGroup.Player, SkillOrbInteractionSpline.character, SpiritModeShellAnimator.SpiritModeShellAnimator, SplineParticlesPooled.character, TelescopicPickup.character, ReviveCompletableActivity.playerCharacter, ReviveCompletableActivity.ReviveCompletableActivity.