SetUnitLookAt
- Parameters
whichUnit unitThe unit that will have its bone locked to face the target.
whichBone stringString 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"
lookAtTarget unitThe bone will be locked to face this unit.
offsetX realThe x-offset from lookAtTarget's origin point.
offsetY realThe y-offset from lookAtTarget's origin point.
offsetZ realThe 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:
- 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"->[] - The
whichBoneargument is tokenized the same way, but unrecognized substrings are replaced by"bone_head". Example:"bone_hand alternate one"->["bone_hand", "alternate", "bone_head"] - For each bone, the number of matching tokens (order doesn't matter) is counted against
whichBonetokens. 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).
- 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:
- note
SetUnitLookAt is affected by animation speed and blend time.
- note
- bug
The dropdown in the GUI only has
"bone_head"and"bone_chest"as possible options for thewhichBoneargument.- 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