IEnumerator MoveSloth(bool isRight, float holdTime) {
//Play Arm extend animation
Vector3 relativeForce;
if (isRight) {
_animator.SetBool("MoveRight", true);
StartCoroutine(RotateSloth(new Vector3(0, ROTATIONFORCE, 0), rotationAnimationTime * 2f, rotationAnimationCurve));
relativeForce = _rigidBody.transform.rotation * new Vector3(SIDEFORCE, 0, FORWARDFORCE);
} else {
_animator.SetBool("MoveLeft", true);
StartCoroutine(RotateSloth(new Vector3(0, -ROTATIONFORCE, 0), rotationAnimationTime * 2f, rotationAnimationCurve));
relativeForce = _rigidBody.transform.rotation * new Vector3(-SIDEFORCE, 0, FORWARDFORCE);
}
yield return new WaitForSeconds(ANIMTIMEBEFOREMOVE);
if (isRight) _animator.SetBool("MoveRight", false);
else _animator.SetBool("MoveLeft", false);
//Apply force
if (isRight) {
if(!_hasHitWallRight) StartCoroutine(PushSloth(relativeForce)); //Push only if wall wasnt hit
} else {
if (!_hasHitWallLeft) StartCoroutine(PushSloth(relativeForce));
}
}