Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit44fd9e59bd

README.md

IKAim

Turns a bone chain until a named axis on its tip points at a target. Where IKLimb drives a tip to a position, this drives it to an orientation — it is what aims a weapon barrel, a turret, a sensor, or a spotlight.

turret.component.add("IKAim", { rootBone = "base", tipBone = "barrel", target = enemyRef, axisZ = 1 })

Fields

  • role or rootBone + tipBone — which chain turns.
  • target — an EntityRef.
  • axisX / axisY / axisZ — the tip's local aiming direction, default +Z. A barrel modelled down +Y sets axisY = 1 and axisZ = 0.
  • weight — blends against the incoming animation; 0 is an exact pass-through.
  • iterations — aiming is iterative because turning a bone also moves the tip, which changes the direction to the target.

Checking it

turret.component.get("IKAim"):aimState()
-- { ready, status, boneCount, aimErrorDegrees, weight, error }

aimErrorDegrees is the angle still between the tip's axis and the target. If it stays large, check the axis before anything else.