Skip to main content

Class PointingHandler

Manages a pedestrian character's pointing animation and body orientation toward a designated target using Unity's Animation Rigging package.

[RequireComponent(typeof(Rigidbody))]
public class PointingHandler : MonoBehaviour

Inheritance​

Remarks​

This component enables pedestrian pointing behavior, allowing the character to direct participant attention to specific stimuli (e.g. a vehicle about to yield).

Pointing is achieved in two stages. First, the Animator transitions into a pointing clip via the isAiming parameter; simultaneously, DOTween tweens m_controlRig.weight from 0 to 1, blending the rig layer over whatever base animation was already playing instead of cutting to it abruptly. Second, a UnityEngine.Animations.Rigging.MultiAimConstraint inside that rig applies IK to drive the arm bone toward m_pointTarget in world space, so the outstretched hand tracks the target continuously regardless of which base animation is running.

Body rotation toward the target is optional (m_orientRotationToPointTarget) because some scenarios require the pedestrian to point sideways while continuing to face forward.

Properties​

IsPointing​

Indicates whether the character is currently pointing towards the target.

public bool IsPointing { get; }

Property Value​

bool

Methods​

EnablePointing(bool)​

Enables or disables the pointing behavior.

public void EnablePointing(bool value)

Parameters​

NameTypeDescription
valueboolIf true, activates pointing; otherwise, deactivates pointing.

SetPointActive(Transform)​

Sets or changes the character's pointing target.

public void SetPointActive(Transform target)

Parameters​

NameTypeDescription
targetTransformThe Transform that the character should point towards. This can be any valid scene object (enemy, item, marker, etc.).

SetPointTargetAndConstraintSource(Transform)​

Sets the character's point target and updates the source object in the associated aim constraint.

public void SetPointTargetAndConstraintSource(Transform target)

Parameters​

NameTypeDescription
targetTransformThe Transform that the character should point towards.

Remarks​

When called, this method will finds the MultiAimConstraint components that are child of the m_controlRig?text=rig and replaces its view target (the first element in MultiAimConstraintData.sourceObjects) with the specified target.

  • Remarks
  • Properties
    • IsPointing
  • Methods
    • EnablePointing(bool)
    • SetPointActive(Transform)
    • SetPointTargetAndConstraintSource(Transform)