Hello,
iam trying to get my animationlayer working. Currently ive got 2 Layers in my AnimatorController. While the baselayer is without weaponShaking, and the other with Weaponshaking.
I want the weaponshaking to stop when player shoots, and enable it again after time x.
While this works when setting it manually, it just wont work in code at all. Well it stops and starts again, but when interrupting the coroutine ( firing faster or more than 1 time before it stops again ) wont interrupt it and makes it run indefinitely.
What am i doing wrong ? I also tried the coroutine to not be saved into an Ienumerator but then it leads to not stop the coroutine. And i cant stop all coroutines, because the weapon is holding more that just this one.
Thank you.
Justin
public IEnumerator SetWeaponShaking()
{
yield return new WaitForSeconds(5f);
playerController.playerCore.anim.SetLayerWeight(1, 1);
}
public void SetWeaponShaking(int value)
{
if (value < 1)
{
if(weaponShakingRoutine != null)
StopCoroutine(weaponShakingRoutine);
playerController.playerCore.anim.SetLayerWeight(1, value);
}
else
weaponShakingRoutine = SetWeaponShaking();
StartCoroutine(weaponShakingRoutine);
}