Animator MatchTarget Problem On OverRide Animation Layer (Has GIF)
Hey.
So im making a character Controller and adding animations where the character jumps over a barricade. In mecanim i have a Locomotion Layer(handles movement) then an Override Layer(handles the jumping over barricade), my actual set up is much more complicated then this, but this simple set up reproduces the problem.
Im Having problems with the Jump Animations. This state has a Behaviour (IMPORTANT) so when the Jump State is playing we match target.
here is the code for the Behaviour:
public class TestBehaviour : StateMachineBehaviour {
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
animator.transform.position = GameObject.Find("StartPos").transform.position;
animator.transform.rotation = GameObject.Find("StartPos").transform.rotation;
//-------- StatePos(YELLOW SPHERE) gameobject is so when the animation states we are in the correct position
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
animator.MatchTarget(GameObject.Find("HandPos").transform.position, GameObject.Find("HandPos").transform.rotation, AvatarTarget.RightHand, new MatchTargetWeightMask(Vector3.one, 0f), 0.15f, 0.6f);
//-------- HandPos(RED SPHERE) is the gameobject's position for where we want our Righthand to matchTarget
}
}
In the code each frame the state is playing we are MatchingTarget. HandPos(RED Sphere's transform) is the target and we are moving our Right Hand to it.
Now this is what happens. The Green Wire Sphere is suppose to be the right hand and we are matching target to The top of the of the blue barricade where the red sphere is but when the animation starts the Green Wire Sphere is out in front of the character not Where his right hand is. This causes the match target to not work at all
------------>GIF of the problem
I know this GIF is extremely bad quality it was recorded on my phone compressed in movie maker and made into a gif on a free website. BUT hopefully it will get across the problem im having better then images and text.
Thanks for taking the time to read my question, Hope someone can help ~Scott
Please Note that if the "Jump" animation plays in the Locomotion Layer(base layer) it works perfectly. But my character isnt set up like that, thats why it must be in a separate override layer
Hi. I have exactly same issue! It only works in the base layer! did you solve this?