MasterNin ECSAnimator
On this page

Crossbow IK: aim at a changing target height

Adjust crossbow aim while the base animation keeps playing. The supplied examples use two arm chains and foregrip following; no separate animation is needed for each target height.

Try the new Aim Idle comparison

  1. Import Demos from Package Manager > ECSAnimator > Samples.
  2. Stop Play. Select Tools > ECSAnimator > Demos > Use URP Preview or Use HDRP Preview, matching your project.
  3. Open 14_TwoBoneIK/Pages/AimIdle/Scenes/AimIdle.unity and enter Play.
  4. Use Auto target height, Target elevation, Enable arm IK and IK strength.

Expected result: blue keeps the authored Aim Idle; red adjusts its arms and crossbow pitch toward the target. At zero strength, red returns to its moving source pose. Body heading, waist and feet keep the authored animation.

The red ray starts at the central bolt rail and follows the weapon's actual direction. Muzzle 3D error measures the full angle to the target. Clamping, partial strength, disabled IK or sideways targets can leave the ray missing the red dot. The display does not force it to connect.

See the Aim Idle sample guide for its controls and resource entry.

Try the original Attack comparison

Open 14_TwoBoneIK/Scenes/14_TwoBoneIK.unity after the same pipeline setup. Leave Auto attack enabled to see IK blend with Attack. Toggle Enable IK, change Target elevation and adjust IK strength to compare.

Hold aiming pose holds the original Attack animation at normalized time 0.25. Release it to resume playback. The independent Aim Idle scene does not need this toggle or an Attack trigger.

What changes, and what stays animated

The examples change vertical pitch about character-root X. They do not turn the character toward sideways targets. The Aim Idle launch rail is authored facing character-forward (+Z), so its horizontal heading follows the character without muzzle-yaw compensation.

Height, forward distance and the muzzle's positional offset from the shoulder pivot determine aim. The right arm places the weapon; the left hand follows the solved foregrip. Bone lengths stay fixed and unreachable hand targets clamp without stretching. The default pitch limit is +/-45 degrees; small numerical reconstruction errors remain visible in the measurements.

Integrate with your gameplay

  1. Enable Require Pose Processing during conversion, then rebuild the EntityDesc. Confirm prepared.SupportsPoseProcessing.
  2. Resolve the exported bone indices. Supply root-space targets, rotations, elbow hints and weights through the pose API.
  3. Use the sample's CrossbowPoseProcessor as a reference: solve the right arm, read the solved foregrip, then solve the left arm.

Processing runs after Animator blending and before skinning/attachment output. Ordinary characters can omit it. The pose API explains callback lifetime and scheduling; the sample source contains the integration.

Support boundaries

Dependency baseline

Use the package's declared dependency baseline. Native Editor crashes during some IK/crowd Play/Stop transitions remain unresolved; see known issues. Changing Burst or disabling IK/rays is not an established fix.

Imported Samples are project-owned copies. Preserve your edits before refreshing them after an upgrade.