- Home /
This question was
closed May 25, 2019 at 12:02 AM by
DoctorChar for the following reason:
Problem is not reproducible or outdated
Question by
DoctorChar · May 24, 2019 at 03:40 AM ·
animationanimationsglitch
animations repeating unwantedly
Hello,
I am making a fighting game with shielding, however when I try to activate or deactivate the shield, (which are separate animations) they play 2 or 3 times. Here is my script.
if (anim.GetBool("IsAirborn") == false && Input.GetKeyDown(KeyCode.I) && shielding == false)
{
ShieldingAnimationDone = false;
anim.SetInteger("AnimParameter", 6);
shield.SetActive(true);
coroutine = WaitForShield(0.167f);
StartCoroutine(coroutine);
}
and my I enumerator
private IEnumerator WaitForShield(float waitTime)
{
print("hi1");
yield return new WaitUntil((() => !Input.GetKey(KeyCode.I)));
print("hi2");
anim.SetInteger("AnimParameter", 7);
print(anim.GetInteger("AnimParameter"));
yield return new WaitForSeconds(waitTime);
print("hi3");
shield.SetActive(false);
ShieldingAnimationDone = true;
}
They are four frame animations if it helps.
animationglitch.png
(40.4 kB)
Comment