NWAvatar

csharp
public class NWAvatar : MonoBehaviour, NodeWorld.Avatar.IAvatarViewpointProvider

Namespace global.

Avatar descriptor for NodeWorld. Place on the root of any humanoid avatar. Auto-detects the full skeletal structure via Unity's Humanoid Avatar system (Animator.GetBoneTransform), validates the rig against IK requirements, computes body measurements from bone positions, and exposes a clean read-only API for the runtime IK and animation systems to consume. Detection is deterministic: no name matching, no hierarchy walking, no guessing. Every bone comes from Animator.GetBoneTransform which is Unity's authoritative humanoid bone mapping. Zero runtime cost after initialization (no Update/LateUpdate).

Fields

RequiredBones

csharp
public static readonly HumanBodyBones[] RequiredBones

The 15 bones required for full-body IK: hips, spine, head, both arms (upper, lower, hand), both legs (upper, lower, foot).

OptionalBones

csharp
public static readonly HumanBodyBones[] OptionalBones

Optional non-finger bones. Missing ones produce individual warnings.

Properties

IsValid

csharp
public bool IsValid { get; }

True if the rig passed validation: all required bones present, Animator is humanoid.

IsDetected

csharp
public bool IsDetected { get; }

True after Detect has been called at least once.

Errors

csharp
public IReadOnlyList<string> Errors { get; }

Hard failures — missing required bones, non-humanoid Animator, etc.

Warnings

csharp
public IReadOnlyList<string> Warnings { get; }

Soft issues — missing optional bones, no eye bones, etc.

Animator

csharp
public Animator Animator { get; }

The avatar's Animator component.

Measurements

csharp
public NWAvatarMeasurements Measurements { get; }

Body measurements computed from bone positions at detection time.

SkinnedRenderers

csharp
public IReadOnlyList<SkinnedMeshRenderer> SkinnedRenderers { get; }

Skinned mesh renderers found on this avatar.

VisemeMap

csharp
public NWVisemeMap VisemeMap { get; }

Detected viseme blendshape map, or an empty map when none are available.

UsesManualVisemeMapping

csharp
public bool UsesManualVisemeMapping { get; }

True when this avatar uses explicit inspector-assigned visemes.

ViewPosition

csharp
public Vector3 ViewPosition { get; set; }

Viewpoint position in avatar-local space. Serialized, user-adjustable.

ViewpointWorldPosition

csharp
public Vector3 ViewpointWorldPosition { get; }

Viewpoint position in world space.

HeadTrackingOffset

csharp
public Vector3 HeadTrackingOffset { get; }

Offset from the viewpoint (eyes) to the head bone, in the avatar's space: the camera's space when the player looks straight ahead. Not in the head bone's space: its axes are those of the program the avatar was made in, not the camera's. Used when driving the IK head target so the XR camera sits at the avatar's eyes while the solver head target lands on the head bone.

HeadRotationInView

csharp
public Quaternion HeadRotationInView { get; }

The head bone's rotation in the avatar's space: how the bone is turned when the camera looks straight ahead. The IK head target is the camera's rotation times this one; the camera's rotation alone turned the head, and the chest that follows it, on an avatar whose head bone does not have the camera's axes.

IsLocalPlayer

csharp
public bool IsLocalPlayer { get; set; }

True if this avatar is driven by the local VR player. Set by NWAvatarController when the avatar is activated. Used by local-only systems such as first-person head culling.

Hips

csharp
public Transform Hips { get; }

The hips bone from the Animator's humanoid mapping, or null when the avatar has none.

Spine

csharp
public Transform Spine { get; }

The spine bone from the Animator's humanoid mapping, or null when the avatar has none.

Chest

csharp
public Transform Chest { get; }

The chest bone from the Animator's humanoid mapping, or null when the avatar has none.

UpperChest

csharp
public Transform UpperChest { get; }

The upper chest bone from the Animator's humanoid mapping, or null when the avatar has none.

Neck

csharp
public Transform Neck { get; }

The neck bone from the Animator's humanoid mapping, or null when the avatar has none.

csharp
public Transform Head { get; }

The head bone from the Animator's humanoid mapping, or null when the avatar has none.

LeftShoulder

csharp
public Transform LeftShoulder { get; }

The left shoulder bone from the Animator's humanoid mapping, or null when the avatar has none.

LeftUpperArm

csharp
public Transform LeftUpperArm { get; }

The left upper arm bone from the Animator's humanoid mapping, or null when the avatar has none.

LeftLowerArm

csharp
public Transform LeftLowerArm { get; }

The left lower arm bone from the Animator's humanoid mapping, or null when the avatar has none.

LeftHand

csharp
public Transform LeftHand { get; }

The left hand bone from the Animator's humanoid mapping, or null when the avatar has none.

RightShoulder

csharp
public Transform RightShoulder { get; }

The right shoulder bone from the Animator's humanoid mapping, or null when the avatar has none.

RightUpperArm

csharp
public Transform RightUpperArm { get; }

The right upper arm bone from the Animator's humanoid mapping, or null when the avatar has none.

RightLowerArm

csharp
public Transform RightLowerArm { get; }

The right lower arm bone from the Animator's humanoid mapping, or null when the avatar has none.

RightHand

csharp
public Transform RightHand { get; }

The right hand bone from the Animator's humanoid mapping, or null when the avatar has none.

LeftUpperLeg

csharp
public Transform LeftUpperLeg { get; }

The left upper leg bone from the Animator's humanoid mapping, or null when the avatar has none.

LeftLowerLeg

csharp
public Transform LeftLowerLeg { get; }

The left lower leg bone from the Animator's humanoid mapping, or null when the avatar has none.

LeftFoot

csharp
public Transform LeftFoot { get; }

The left foot bone from the Animator's humanoid mapping, or null when the avatar has none.

LeftToes

csharp
public Transform LeftToes { get; }

The left toes bone from the Animator's humanoid mapping, or null when the avatar has none.

RightUpperLeg

csharp
public Transform RightUpperLeg { get; }

The right upper leg bone from the Animator's humanoid mapping, or null when the avatar has none.

RightLowerLeg

csharp
public Transform RightLowerLeg { get; }

The right lower leg bone from the Animator's humanoid mapping, or null when the avatar has none.

RightFoot

csharp
public Transform RightFoot { get; }

The right foot bone from the Animator's humanoid mapping, or null when the avatar has none.

RightToes

csharp
public Transform RightToes { get; }

The right toes bone from the Animator's humanoid mapping, or null when the avatar has none.

LeftEye

csharp
public Transform LeftEye { get; }

The left eye bone from the Animator's humanoid mapping, or null when the avatar has none.

RightEye

csharp
public Transform RightEye { get; }

The right eye bone from the Animator's humanoid mapping, or null when the avatar has none.

Jaw

csharp
public Transform Jaw { get; }

The jaw bone from the Animator's humanoid mapping, or null when the avatar has none.

Methods

GetBone

csharp
public Transform GetBone(HumanBodyBones bone)

Returns the cached Transform for a humanoid bone. O(1) array lookup. Returns null if the bone is not mapped in the humanoid Avatar.

HasBone

csharp
public bool HasBone(HumanBodyBones bone)

True if the bone exists in the humanoid Avatar mapping.

Detect

csharp
public void Detect()

Runs the full detection pipeline: finds the Animator, maps all humanoid bones, validates required bones, computes body measurements, and catalogues skinned renderers. Does NOT modify viewPosition — call AutoDetectViewpoint separately for that. Safe to call in both edit mode and play mode.

AutoDetectViewpoint

csharp
public Vector3 AutoDetectViewpoint()

Computes the viewpoint position from eye bones (midpoint) or the head bone if no eyes are mapped. Returns the local-space position. Call this to populate or reset viewPosition: avatar.ViewPosition = avatar.AutoDetectViewpoint();

ApplyFirstPersonVisibility

csharp
public void ApplyFirstPersonVisibility(bool hide)

Hides the head and what hangs from it for the local player's own view (first person), or shows it again.