vedaloivdocs

Reference

Interfaces

Documentation for v1.6.0namespace PlayerC# and UnityEvent

The public runtime API of Easy FP Full Body Controller. Most code only needs PlayerController, which links to every subsystem. Everything is in the namespace Player unless noted.

On this page
  1. PlayerController
  2. State (read-only)
  3. Control methods
  4. PlayerSettings
  5. PlayerInputHandler
  6. Per-frame state
  7. Methods
  8. PlayerLocomotion
  9. Configurable fields
  10. State
  11. PlayerCameraController
  12. Configurable fields
  13. Public API
  14. Items
  15. HandItemSocket: the event source
  16. ItemContainer: the item list
  17. ItemHoldData: per-item configuration
  18. ItemDefinition
  19. ItemAttachmentData
  20. ItemIKPreset
  21. Event API
  22. Payloads
  23. Item events: HandItemSocket
  24. Locomotion events: PlayerLocomotion
  25. Footstep and vitals events
  26. Listener interfaces
  27. Subscribe in code
  28. FPCutter: FPCutterController
  29. PlayerAnimatorController
  30. Feet, hands, head and vitals
  31. PlayerFootPlanting
  32. PlayerFootsteps
  33. HandPoseController and FingerPose
  34. PlayerVitals and PlayerExertion
  35. PlayerHeadIK
  36. PlayerHandIK
  37. PlayerSpineStabilizer
  38. Multiplayer add-on bridges
  39. Demo classes

PlayerController#

The hub on the player root. In Awake it fills in any subsystem reference you left empty, so external code needs one reference.

PropertyTypeSubsystem
SettingsPlayerSettingstuning asset
InputPlayerInputHandlerinput state
LocomotionPlayerLocomotionmovement and physics
CameraControllerPlayerCameraControllerfirst-person camera
AnimatorControllerPlayerAnimatorControlleranimator parameters and item layers
HeadIK, HandIK, SpineStabilizerPlayerHeadIK, PlayerHandIK, PlayerSpineStabilizerhead, hand and spine IK
FootPlantingPlayerFootPlantingground-anchored feet
HandItemSocketHandItemSocketitem equip and unequip

State (read-only)#

MemberTypeNotes
IsGrounded, IsSprintingboolfrom PlayerLocomotion
MoveInput, LookInputVector2from PlayerInputHandler
FlashlightTriggeredbooltrue for the frame the flashlight key is pressed
CurrentSpeed, MaxSpeedfloathorizontal speed, and the maximum for the current state

Control methods#

Use these for menus, cutscenes and pausing.

MethodNotes
SetInputEnabled(bool)Disabling also clears held input.
SetMovementEnabled(bool), SetCameraEnabled(bool)Toggle locomotion and the camera.
SetHeadIKEnabled(bool), SetHandIKEnabled(bool), SetSpineStabilizationEnabled(bool)Toggle one IK subsystem.
SetFootIKEnabled(bool)Toggles PlayerFootPlanting.
SetExternalControlEnabled(bool)For external drivers that move the player instead of local input.
SetCursorLocked(bool)Locks or frees the cursor.
DisableAllControls(), EnableAllControls()Stop or resume all gameplay controls.
var player = GetComponent<PlayerController>();
player.DisableAllControls();   // enter cutscene or menu
// ...
player.EnableAllControls();    // resume gameplay

PlayerSettings#

A ScriptableObject, created with Create › Player › Settings. Most components read their values from it, so it is the single place to tune the feel. When an asset is assigned, its values override the fields on the components. beginnerMode switches the Inspector to a simplified view.

walkSpeed float default 3
Walking speed in units per second.
sprintSpeed float default 6
Sprinting speed in units per second.
crouchSpeed float default 1.5
Speed while crouching.
crouchHeight, standHeight float default 1 and 2
Height of the CharacterController while crouching and standing.
crouchTransitionSpeed float default 8
Speed of the crouch and stand transition.
jumpHeight float default 1.2
Jump height in units.
gravity float default −15
Gravity. Keep it negative.
groundCheckDistance float default 0.2
Distance below the player that counts as ground.
groundedVelocityReset float default −2
Vertical velocity applied while grounded, to keep the player on slopes and stairs.
inputDeadzone float default 0.01
Smallest input magnitude that counts as movement.
animationSmoothTime float default 0.1
Smoothing of the animator's float parameters.
sprintAnimMultiplier float default 1.5
Animation speed multiplier while sprinting.
defaultHeadHeight float default 1.6
Head height when no head bone is assigned.
lookTargetDistance float default 2
Distance of the look target in front of the player.
cameraFallbackHeadHeight float default 1.7
Camera height when the head bone is not assigned.
verticalLookLimit float default 80
Maximum vertical look angle in degrees.
handVerticalLimitUpper, handVerticalLimitLower float default 45
Look angle, up and down, beyond which the hand IK stops following the view.
enableSpineStabilization bool default true
Turns spine stabilization on or off.
spineStiffness, spineDamping float default 1 and 10
Strength and smoothing of the spine correction.
lowerSpineWeight, middleSpineWeight, upperSpineWeight float default 0.3, 0.3, 0.4
Share of each spine segment in the correction.

PlayerInputHandler#

Reads the FBInputActions asset, using the action map named by actionMapName (default Player).

Per-frame state#

MemberTypeNotes
MoveInputVector2X is strafe, Y is forward, from −1 to 1
LookInputVector2X is horizontal, Y is vertical
IsSprintingboolsprint is held
IsCrouchingbooltoggled on each press of Crouch
JumpTriggeredbooltrue for the single frame of the press
FlashlightTriggeredbooltrue for the single frame of the press (uses the held item)
InteractTriggeredbooltrue for the single frame the Interact action is pressed

Methods#

LockCursor() hides and locks the cursor for gameplay. UnlockCursor() frees it for UI.

The shipped Player map defines Move, Look, Sprint, Jump, Crouch, Flashlight, Interact, Attack, Previous and Next. Previous, Next and Attack are not read by the shipped code.

PlayerLocomotion#

Requires a CharacterController. It fires the locomotion events listed under Event API.

Configurable fields#

Speeds, heights and gravity mirror the values in PlayerSettings. When a settings asset is assigned, the asset wins. Other fields:

groundLayers LayerMask default all layers
Layers that count as ground.

State#

MemberTypeNotes
IsGroundedbooltrue while touching the ground
IsCrouchingbooltrue in the crouch state
IsSprintingbooltrue only while grounded and sprinting
CurrentSpeed, MaxSpeedfloatcurrent horizontal speed, and the maximum for the current state (crouch, walk or sprint)
CrouchFactorfloatcrouch progress
RegisterListener, UnregisterListenerILocomotionEventListeneradd or remove a listener at runtime

PlayerCameraController#

Drives a Cinemachine camera. The camera target follows the head bone and does not inherit the head's animation sway.

Configurable fields#

eyeOffset Vector3 default (0, 0.05, 0.1)
Offset from the head bone while standing.
crouchEyeOffset Vector3 default (0, 0.05, 0.05)
Offset from the head bone while crouching.
lookSensitivity float default 0.1
Look sensitivity multiplier.
verticalLookLimit float default 80
Maximum vertical look angle in degrees, used when no settings asset is assigned.

Public API#

MemberSignatureNotes
CameraTargetTransformthe transform the Cinemachine camera follows
Pitch, Yawfloatcurrent look angles in degrees
GetLookAnglesVector2 GetLookAngles()X is yaw, Y is pitch
SetLookDirectionSetLookDirection(float yaw, float pitch)sets the look direction, for example after a respawn
SyncCameraTargetToHeadSyncCameraTargetToHead()runs in LateUpdate; call it yourself after you change the head pose
SetVerticalLimitOverride, ResetVerticalLimitOverrideSetVerticalLimitOverride(float upper, float lower)asymmetric look limits, used by item IK data
SetBodyYawOverride, ClearBodyYawOverrideSetBodyYawOverride(float targetYaw)overrides the body yaw
EnsureCameraTargetEnsureCameraTarget()creates or reassigns the camera target if it is missing
SetLocalCameraActive, IsLocalCameraActiveSetLocalCameraActive(bool), boolenables the local camera. The FishNet add-on disables it on remote players.

Items#

How items are set up and used is explained in Items. This section lists the API.

HandItemSocket: the event source#

The single owner of equip and unequip events. A switch plays the holster animation: the current item is lowered out of view, then the new one is raised.

MemberTypeNotes
CurrentItem, HasItemGameObject, boolthe logical current item, which changes at once when a switch starts
StowingItemGameObjectthe old item still being lowered during a switch
PendingItemGameObjectthe new item waiting to be drawn
IsTransitioningbooltrue while a switch is in progress
Socket, LocomotionTransform, PlayerLocomotionthe socket transform, and the locomotion used for crouch offsets
MethodSignatureNotes
AttachItemAttachItem(GameObject, Vector3? positionOffset = null, Vector3? rotationOffset = null) or AttachItem(GameObject, ItemAttachmentData)attaches an item to the socket
DetachItemGameObject DetachItem(bool destroy = false)detaches the current item
EquipFromContainerEquipFromContainer(GameObject item, int slotIndex = -1)equips an item from a container and applies its ItemHoldData
UnequipToContainerUnequipToContainer() or UnequipToContainer(bool hideImmediately)returns the item to its container. The parameterless overload is kept for existing UnityEvent wiring.
HideStowingItem, CompleteTransitionImmediatelyvoidhide the item being lowered, or finish a running switch at once
UseCurrentItemvoidfires OnUse on the equipped item. It is ignored until the new item is drawn.
RegisterListener, UnregisterListenerIItemEventListeneradd or remove an item listener at runtime

Inspector fields on HandItemSocket: Smooth Transitions (smoothTransitions, default on; off gives the previous instant switch) and Stow Timeout (stowTimeout, default 1 second).

ItemContainer: the item list#

Holds the items and equips them through the socket. It does not emit equip events itself.

MemberSignatureNotes
CurrentItem, HasEquippedItem, CurrentIndexpropertythe equipped item, whether one is equipped, and its index (−1 for none)
ItemCount, HandSocketpropertynumber of items, and the socket the items are equipped through
EquipItemEquipItem(int index), EquipItem(GameObject item)equips by list index, or by a listed item
EquipItemByIdEquipItemById(string id)equips by the item's id
EquipNext, EquipPreviousvoid EquipNext(), void EquipPrevious()cycle through the items and wrap around
UnequipCurrentUnequipCurrent() or UnequipCurrent(bool hideImmediately)puts the current item away
GetItem, GetItemByIdGetItem(int index), GetItem(ItemDefinition definition), GetItemById(string id)gets an item without equipping it
AddItemAddItem(GameObject item)adds an item, inactive until equipped, and fires OnContainerChanged
RemoveItembool RemoveItem(GameObject item)unequips the item first if it is equipped, and fires OnContainerChanged

Event: OnContainerChanged (UnityEvent), fired when the item list changes.

ItemHoldData: per-item configuration#

Attached to the item GameObject. With an ItemDefinition assigned, the id, category and world prefab come from the definition.

MemberTypeNotes
ItemIdstringthe effective id: the definition's id, or itemId (default NewItem)
DefinitionItemDefinitionthe assigned definition, or null
CategoryItemCategorythe effective category
Is(ItemCategory flags)booltrue when all given flags are set
AttachmentDataItemAttachmentDatathe hold and IK configuration
WorldItemPrefabGameObjectthe prefab spawned when the item is dropped
OnEquip, OnUnequip, OnUseUnityEventitem-local reactions. OnEquip and OnUnequip only fire for items that are shown.

ItemDefinition#

A ScriptableObject, created with Create › Player › Item Definition. It describes an item in one place.

MemberTypeNotes
Idstringthe locked id, or the id derived from the asset name
IsIdLockedbooltrue once the id is locked
DisplayNamestringname shown in UI. Falls back to the asset name.
CategoryItemCategorycategory flags
HeldPrefab, WorldPrefab, NetworkPrefabGameObjectprefabs for the hand, the world and the network
Is(ItemCategory flags)booltrue when all given flags are set
ItemDefinition.ToId(string assetName)static stringderives an id from an asset name

ItemCategory is a flags enum: None, Tool, Electric, Consumable. An item can have several categories.

ItemAttachmentData#

The hold, grip and IK data of an item. Its fields are listed in Items: Grips and IK. The key members are holdStyle (OneHandedRight or TwoHanded), gripPositionOffset, gripRotationOffset, the override… switches with their hand and elbow offsets, fingerPoseRight and fingerPoseLeft, and the vertical limits.

ItemIKPreset#

A ScriptableObject, created with Create › Player › Item IK Preset. It stores an ItemAttachmentData in its data field.

MemberSignatureNotes
ApplyToApplyTo(ItemAttachmentData target)copies the preset into an item's data
CaptureFromCaptureFrom(ItemAttachmentData source)copies an item's data into the preset
CaptureFromScene, ApplyToScenecontext menucapture or apply the data of a scene object that the preset references

Event API#

Every equip, unequip, locomotion change, footstep and vitals change is announced once, in three ways:

MechanismFor
C# eventcode subscribers. Struct payloads avoid allocations per call.
UnityEventInspector wiring without code
Listener interfacesstructured extension. Any component in the player hierarchy that implements one is found at startup.

Payloads#

ItemEquipArgs
Item (GameObject), SlotIndex (int, −1 if the item did not come from a container), HoldData (ItemHoldData), FromContainer (bool).
LandArgs
ImpactVelocity (float, negative when falling), FallDistance (float).
FootStepArgs
IsLeft (bool), Point (Vector3, world position), IsReStep (bool, true for a procedural re-step).

Item events: HandItemSocket#

C# eventTypeUnityEvent
ItemEquippedAction<ItemEquipArgs>OnItemEquipped (ItemEvent)
ItemUnequippedAction<ItemEquipArgs>OnItemUnequipped (ItemEvent)

With smooth transitions, ItemUnequipped fires while the old item is still visible. ItemEquipped can fire for an item that is still waiting to be drawn.

Locomotion events: PlayerLocomotion#

C# eventTypeUnityEvent
JumpedActionOnJumped
LandedAction<LandArgs>OnLanded
CrouchStarted, CrouchEndedActionOnCrouchStarted, OnCrouchEnded
SprintStarted, SprintEndedActionOnSprintStarted, OnSprintEnded
GroundedChangedAction<bool>OnGroundedChanged

Footstep and vitals events#

SourceC# eventUnityEvent
PlayerFootstepsFootPlanted (Action<FootStepArgs>)OnFootPlanted
PlayerFootPlantingReStepLanded (Action<FootStepArgs>)none
PlayerVitalsHealthChanged (Action<float>), Died, RevivedOnHealthChanged, OnDied, OnRevived

Listener interfaces#

Implement only the methods you need. The others are no-ops. Use RegisterListener for objects that are added at runtime.

  • IItemEventListener: OnItemEquipped(ItemEquipArgs), OnItemUnequipped(ItemEquipArgs)
  • ILocomotionEventListener: OnJumped(), OnLanded(LandArgs), OnCrouchStarted(), OnCrouchEnded(), OnSprintStarted(), OnSprintEnded(), OnGroundedChanged(bool)
using Player;
using UnityEngine;

public class MyListener : MonoBehaviour, IItemEventListener, ILocomotionEventListener
{
    public void OnItemEquipped(ItemEquipArgs args) => Debug.Log($"equipped {args.Item.name}");
    public void OnLanded(LandArgs args) => Debug.Log($"landed at {args.ImpactVelocity} m/s");
}
MethodNotes
locomotion.RegisterListener(ILocomotionEventListener)adds a locomotion listener at runtime
socket.RegisterListener(IItemEventListener)adds an item listener at runtime
UnregisterListener(...)removes a listener from either source

Subscribe in code#

player.Locomotion.Jumped += () => Debug.Log("jumped");
player.HandItemSocket.ItemEquipped += args =>
    Debug.Log($"equipped {args.Item.name} from slot {args.SlotIndex}");

FPCutter: FPCutterController#

Namespace FPCutter. Hides body parts in first person and keeps their shadows. The FPCutter Wizard generates the controller on a complete copy of the character. See FPCutter.

MemberSignatureNotes
SetFirstPersonSetFirstPerson()hides the parts in Hide In First Person
SetThirdPersonSetThirdPerson()shows all parts
HidePart, ShowPartHidePart(BodyPart part), ShowPart(BodyPart part)control one part
Hide In First Person List<BodyPart> default Head
The parts that are hidden in first person.
Invisible Material Material
The material for hidden parts. It uses the FPCutter/InvisibleShadowCaster shader.

BodyPart (in the FPCutter namespace) has the values Body, Head, LeftArm, RightArm, LeftLeg and RightLeg.

PlayerAnimatorController#

Drives the animator parameters and the item animation layers.

MemberSignatureNotes
SetItemLayerSetItemLayer(int layerIndex)activates an item animation layer
ToggleFlashlight, SetFlashlightActiveToggleFlashlight(), SetFlashlightActive(bool)the flashlight state
IsFlashlightActivebool (property)true while the flashlight layer is active
TriggerAnimationTriggerAnimation(string triggerName)sets an Animator trigger
GetAnimatorAnimator GetAnimator()returns the Animator

Feet, hands, head and vitals#

The Setup Wizard configures these components. Change them directly only for custom behaviour. The tuning of each is in its guide: Body IK and Vitals.

PlayerFootPlanting#

On the model. Runs at execution order -200, before the camera syncs to the head.

MemberSignature or typeNotes
SetEnabledSetEnabled(bool)turns planting on or off at runtime
ResetPlantingResetPlanting()resets the anchors. Call it after a teleport.
SetExternalDriveState, ClearExternalDriveStateSetExternalDriveState(bool grounded, Vector2 moveDirection)drives a remote player from a network add-on. The PurrNet bridge uses it.
ReStepLandedevent Action<FootStepArgs>fires when a re-step lands
PlantModeenumIdle, Moving, Automatic
StepSettingsnested classre-step duration, path, arc, lift, rotation and catch-up curves

PlayerFootsteps#

On the root. Detects steps from the animated feet, without animation events. It raises FootPlanted and OnFootPlanted, listed under Event API.

HandPoseController and FingerPose#

HandPoseController sits on the model and poses the fingers around the held item. It calibrates from the Humanoid muscle limits.

MemberSignatureNotes
CalibrateFromAvatarbool CalibrateFromAvatar()re-reads the finger limits from the avatar.
RebindRebind()rebinds the finger bones
RecaptureReferenceRecaptureReference()captures the reference pose
SnapSnap()applies the current target at once, for example when an item is equipped at start
ResolvedBoneCountint (property)number of finger bones found

FingerPose is a ScriptableObject created with Create › Player › Finger Grip Pose. Its fields are the five curls (thumbCurl, indexCurl, middleCurl, ringCurl, littleCurl), thumbOpposition and spread. ToValues() and FromValues(...) convert to and from FingerPoseValues.

PlayerVitals and PlayerExertion#

PlayerVitals is optional and sits on the root. Its health and stamina are described in Vitals and Stamina.

MemberSignature or typeNotes
Health, MaxHealth, NormalizedHealthfloat (properties)current and maximum health, and the 0 to 1 fraction
IsDeadbooltrue at zero health
ApplyDamage, Healbool ApplyDamage(float amount), bool Heal(float amount)false when ignored (dead player, or an amount that is zero, negative, NaN or infinite)
Revivebool Revive()restores a dead player to full health. Returns false for a living player.
SetHealthvoid SetHealth(float value)sets the value, clamped to 0 and MaxHealth. Use it to mirror a server value.
Bpm, CanSprintfloat, bool (properties)heart rate, and whether sprinting is allowed
ExertionPlayerExertion (property)the stamina model, with Bpm, Exhausted, NeedsSprintRelease and CanSprint

PlayerHeadIK#

MemberSignatureNotes
Weightfloat (property)current IK weight
SetWeight, SetWeightSmoothSetWeight(float), SetWeightSmooth(float)immediate or smoothed weight
SetWeightsSetWeights(float body, float head, float eyes, float clamp)body, head and eye weights, and the clamp
SetEnabledSetEnabled(bool)turns head look-at on or off

PlayerHandIK#

Hand and elbow IK for held items, including the holster animation. Runs at execution order 20, after head (10) and spine (15).

MemberSignatureNotes
HolsterProgressfloat (property)0 is raised at the item pose, 1 is lowered out of view
SetHolsteredSetHolstered(bool)lowers or raises the hand
BeginDrawBeginDraw()starts raising the hand
SetIKWeight, SetIKWeightSmoothSetIKWeight(float position, float rotation, float hint = 1)right-hand weights. Partial weights stay as set.
SetLeftIKWeightSetLeftIKWeight(float position, float rotation, float hint = 1)left-hand weights for two-handed items
SetTwoHandedSetTwoHanded(bool)fades the left hand on or off
SetEnabledSetEnabled(bool)turns hand IK on or off
IKPositionWeight, IKRotationWeightfloat (properties)right-hand IK weights

The holster timings are Inspector fields under Holster: holsterOffset, holsterTiltAngle, holsterDuration, drawDuration, drawStartWeight, leftHolsterOffset and twoHandedBlendDuration. They are described in Items.

PlayerSpineStabilizer#

Requires an Animator. Keeps the upper body steady while the head looks around. Runs at execution order 15. It is tuned through the spine fields of PlayerSettings.

Multiplayer add-on bridges#

Each optional add-on has one bridge per networking library. Both bridges expose the same item-state method and keep a list of networked world item prefabs.

ClassNamespacePublic API
FishNetPlayerBridgeFBSystem.FishNetNotifyLocalItemStateChanged(ItemEquipArgs). Serialized list: networkWorldItemPrefabs.
PurrNetPlayerBridgeFBSystem.PurrNetNotifyLocalItemStateChanged(ItemEquipArgs). Serialized list: networkWorldItemPrefabs.

The bridges are configured by their Setup Wizards. See Multiplayer (FishNet) and Multiplayer (PurrNet).

Demo classes#

These classes are demo code, not part of the core API. They are in the namespace Player.Demo.

  • PlayerEventLogger: implements both listener interfaces and logs every event. Use it as a template.
  • PlayerInventory: the owned item ids and starter items.
  • PlayerInteraction (E) and PlayerDropSystem (G): pickup and drop.
  • WorldItem: the dropped item. Its itemId must match the item in the container.
  • DemoGuidePanel (F1) and DemoGripToggle (H).