SetUnitLookAt

Parameters
whichUnitunit

The unit that will have its bone locked to face the target.

whichBonestring

String of tokens separated by spaces (case-insensitive). See the list below. Any substring not matching a token is treated as "bone_head". Bone selection rules are described in the note below.

  • "alternate"
  • "bone_chest"
  • "bone_foot"
  • "bone_hand"
  • "bone_head"
  • "bone_turret"
  • "left"
  • "mount"
  • "right"
  • "smart"
lookAtTargetunit

The bone will be locked to face this unit.

offsetXreal

The x-offset from lookAtTarget's origin point.

offsetYreal

The y-offset from lookAtTarget's origin point.

offsetZreal

The z-offset from lookAtTarget's origin point (this already factors in the terrain Z).

comment

Locks a unit's bone to face the target until ResetUnitLookAt is called.

The offset coordinates ( X, Y, Z ) are taken from the target's origin. The bones will lock to the lookAtTarget, offset by those coordinates. You can have only one bone locked to the target at the same time.

note

Bone selection logic:

  1. Each bone in the model has a prop array built by splitting its name by spaces and keeping only recognized tokens (unrecognized substrings are ignored). For example: "bone_hand left" -> ["bone_hand", "left"], "bone_hand_left" -> []
  2. The whichBone argument is tokenized the same way, but unrecognized substrings are replaced by "bone_head". Example: "bone_hand alternate one" -> ["bone_hand", "alternate", "bone_head"]
  3. For each bone, the number of matching tokens (order doesn't matter) is counted against whichBone tokens. The best match is the bone with the most matching tokens. Ties are broken by choosing the bone with the fewest non-matching tokens. If still tied, the first one found is used. If no bone matches, the internal bone ID is set to -1 (nothing is set).
note

SetUnitLookAt is affected by animation speed and blend time.

note

How to instantly set a unit's facing.

bug

The dropdown in the GUI only has "bone_head" and "bone_chest" as possible options for the whichBone argument.

patch

1.00

Source
common.j (suggest an edit or discuss on Github)
return type
nothing
Source code
native          SetUnitLookAt       takes unit whichUnit, string whichBone, unit lookAtTarget, real offsetX, real offsetY, real offsetZ returns nothing