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.