Skip to main content

Animator.MatchTarget(Vector3 matchPosition, Quaternion matchRotation, AvatarTarget targetBodyPart, Vector3 positionXYZWeight , number rotationWeight, number startNormalizedTime, number targetNormalizedTime, number completeMatch = 1)

Automatically adjust the GameObject position and rotation.

Parameters:

NameTypeDescription
matchPositionVector3The position we want the body part to reach.
matchRotationQuaternionThe rotation in which we want the body part to be.
targetBodyPartAvatarTargetThe body part that is involved in the match.
positionXYZWeightVector3weights for matching position
rotationWeightnumberRotation weight.
startNormalizedTimenumberStart time within the animation clip (0 - beginning of clip, 1 - end of clip).
targetNormalizedTimenumberEnd time within the animation clip (0 - beginning of clip, 1 - end of clip), values greater than 1 can be set to trigger a match after a certain number of loops. Ex: 2.3 means at 30% of 2nd loop.
completeMatchnumberAllows you to specify what should happen if the MatchTarget function is interrupted. A value of true causes the GameObject to immediately move to the matchPosition if interrupted. A value of false causes the GameObject to stay at its current position if interrupted.

Usage

---@type Animator
local animator;

---@type Vector3
local matchPosition;

---@type Quaternion
local matchRotation;

---@type AvatarTarget
local targetBodyPart;

---@type Vector3
local positionXYZWeight ;

---@type number
local rotationWeight;

---@type number
local startNormalizedTime;

---@type number
local targetNormalizedTime;

---@type number
local completeMatch;


animator.MatchTarget(matchPosition, matchRotation, targetBodyPart, positionXYZWeight , rotationWeight, startNormalizedTime, targetNormalizedTime, completeMatch)

Extra Detail

Adjust the GameObject position and rotation so that the AvatarTarget reaches the matchPosition when the current state is at the specified progress. Target matching only works on the base layer (index 0). You can only queue one match target at a time and you must wait for the first one to finish, otherwise your target matching will be discarded. If you call a MatchTarget with a start time lower than the clip's normalized time and the clip can loop, MatchTarget will adjust the time to match the next clip loop. For example, start time= 0.2 normalized time = 0.3, start time will be 1.2. Animator.applyRootMotion must be enabled for MatchTarget to take effect.