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
- Import Demos from Package Manager > ECSAnimator > Samples.
- Stop Play. Select Tools > ECSAnimator > Demos > Use URP Preview or Use HDRP Preview, matching your project.
- Open 14_TwoBoneIK/Pages/AimIdle/Scenes/AimIdle.unity and enter Play.
- 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
- Enable Require Pose Processing during conversion, then rebuild the EntityDesc. Confirm
prepared.SupportsPoseProcessing. - Resolve the exported bone indices. Supply root-space targets, rotations, elbow hints and weights through the pose API.
- Use the sample's
CrossbowPoseProcessoras 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
- This is an explicit ECS pose API. Unity Animator IK Pass, OnAnimatorIK, Foot IK and Animation Rigging components are not converted.
- Whole-body IK, automatic terrain adaptation and runtime PlayableGraphs are not supplied.
- Two-bone chains must be direct Root > Mid > Tip hierarchies. Compact MatrixInline2 data cannot be promoted to LocalResolve at runtime.
- Animation LOD controls pose-processing frequency. Do not retain callback pointers, call managed code, change ECS structure or read another character's current-frame pose inside the callback.
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.