I want to centralize my animation parameters. Where should I update them?
So, suppose I want to animate my player character based on its current state (using Unity's state machine-type animator system), and I want to put a block of code along these lines somewhere, to avoid spreading/repeating all of those lines everywhere:
protected void AnimationControl(){
anim.SetBool("Ground", st.IsGrounded);
anim.SetBool("pressing_inputX", inputX != 0);
anim.SetBool("Crouching", st.IsCrouching);
anim.SetBool("Attacking", st.IsAttacking);
}
Now, the problem comes here: https://docs.unity3d.com/Manual/ExecutionOrder.html
I use Coroutines a lot, so I can't put AnimationControl()
inside Update()
, because coroutines could change the states I want the animation parameters to depend on. However, if I put it in LateUpdate()
, my parameters would only update after the internal animation update, so I'd end up with them essentially lagging one frame behind.
(This happened to me and I spent over a year on-and-off trying to fix it before quitting Unity for a while)
My question is, I dunno, what should I do, or what am I doing wrong, or what do you suggest?