- Home /
Mecanim root motion disabled when coroutine kicks in
Hello there,
I'm moving my character with mecanim animation, however when i call a coroutine the animation works ( i can see the transition passes in animator ) but my character stands still.
for example;
void moveWithKeyboard()
{
if (Input.GetKey(KeyCode.W))
{
ethanAnimatior.SetFloat("forwardSpeed", 2f);
//ethan starts to walk here }
if (Input.GetKeyUp(KeyCode.W))
{ethanAnimatior.SetFloat("forwardSpeed", 0f);
//ethan passes to idle state
} }
if(hittedObject.collider.tag.Equals("door"))
{
if (Input.GetKeyDown(KeyCode.F))
{
GameObject subParent = hittedObject.collider.gameObject.transform.parent.gameObject;
GameObject parent = subParent.transform.parent.gameObject;
doorScript doorControlScript = parent.GetComponentInChildren<doorScript>();
doorControlScript.DoorAction(); }
}
Here is the doorcontrol script;
void Update () {
if(isStarted)
{//open the door
startTime = startTime + 0.1f;
doorTransform.position = Vector3.Lerp(startPosition, endPosition, startTime / 1f);
if(startTime>1f)
{
isStarted = false;
//break
}
}
}
public void DoorAction()
{
StartCoroutine(OpenDoor());
}
private IEnumerator OpenDoor()
{
isStarted = true;
yield return new WaitForSeconds(4f);
}
When OpenDoor() kicks in, my animation still goes in but i cannot move my character. It's like Root Motion gets disabled.
Answer by suark · Nov 27, 2015 at 09:58 AM
I have found the solution. Both parent object and children object had rigidbodies, when i removed the rigidbody from children, problem solved.
Your answer
Follow this Question
Related Questions
[Mecanim] Turning animation doesn't rotate the whole way 1 Answer
Why does the top node of the character move instead of specified Root node? 0 Answers
How Unity define transform.forward of humanoid avatar with root motion? 2 Answers
Target Matching in Mecanim not being accurate 2 Answers
Is it possible to mix Root Motion and controller animations? 1 Answer