Trying to understand target matching
So I read all those document, and trying to implement match target, but result are not always expected. Problems :
match target stop before it reach target
AFTER match target complete, something a unexpected force may append on my model.
I had read the API document, and sort out some tips to apply match target.
match target only available on BaseLayer
when (animator.IsInTransition(0) == true) you CANNOT apply match target, warning will append in console
need to wait until GetCurrentAnimatorStateInfo(0).IsName(XXX) return true, which mean it's the animation you wanted to apply MatchTarget.
ensure the match target period are not overlap any other state, (2) happen and match target will cancel.
however, I still can't 100% fix the issue that I had mentioned above. well yeah... by follow the those rules, most of the time work, but not all of it... I record a video to show these problem, https://youtu.be/ju163R2WtM4
and following are the related code used in that video.
// process climb up ledge
animator.SetTrigger(m_LedgeClimb.hash);
// Stay position & wait for animation
rigidbody.isKinematic = true;
Collider surface = hitResult.collider;
Physics.IgnoreCollision(avatar.self.capsule, surface, true);
// Wait for matching
while (!animator.isMatchingTarget)
{
// wait, until we able to use match target.
if (!animator.IsInTransition(0))
{
animator.MatchTarget(landingPoint, predictFacing,
m_UpperHandMatching.m_AvatarTarget,
m_UpperHandMatching.GetWeightMask(),
m_UpperHandMatching.m_Period.x,
m_UpperHandMatching.m_Period.y);
}
yield return null;
}
// Matching
while (animator.isMatchingTarget)
{
yield return null;
}
// re-apply physics
Physics.IgnoreCollision(avatar.self.capsule, surface, false);
rigidbody.isKinematic = false;
hope someone can point out what I'm missing, or the direction thanks.
Physics.IgnoreCollision(); are the key to solve this issue, for some reason the collider that I got was wrong, so it didn't ignore anything in the video.
so yes, the above code are actually working. the glitch that I found was the collider are blocking Or overlapping the model itself. that's what it happen.
Your answer
Follow this Question
Related Questions
Would like to know if I doing well the animation transition? 1 Answer
Animator scripting error C# - Only WalkingRight Movement Animates 0 Answers
Copied character(enemy) not run the animations 0 Answers
How to make player rotate 180° and run that direction with mecanim + vice versa? 1 Answer
Animator vs Animation Clip via Scripting 0 Answers