- Home /
OnStateEnter isn't updating in the correct order with normal update?
It seems to me that OnStateEnter isnt being called in the correct order with an Update. I can prove this is happening by polling the state manually at the start of the update loop, and comparing it to a call made from a OnStateEnter state behaviour that calls back into my core script. as follows.
void Update()
{
bool isLocomotion = animator.GetCurrentAnimatorStateInfo(0).IsName("Locomotion");
if (isLocomotion != locomotionState)
Debug.Log("UNSYNC'D");
if (Input.GetButtonDown("Fire1"))
animator.SetTrigger("Fire1_Pressed");
// if I use locomotionState here, it will get out of sync and result in the release being fired incorrectly.
if (Input.GetButtonUp("Fire1") && !isLocomotion)
animator.SetTrigger("Fire1_Released");
}
// this is called by a SendMessage within the mecanim statebehaviour.
void OnAnimationTrigger(AnimatorStateInfo stateInfo)
{
locomotionState = stateInfo.IsName("Locomotion");
}
My question is, why is this happening. because in the documentation its directly claiming I don't have to poll states anymore and OnStateEnter should be accurate, it is isnt.
Your answer
Follow this Question
Related Questions
How to script SetTrigger (JS)? 1 Answer
How to change speed of the specific state in animator 1 Answer
Animator component prevents NavMeshAgent from disabling/enabling dynamically 0 Answers
Animator does not make transition if speed = 0 3 Answers
What is the proper way to wait for an Animator Controller to update? 1 Answer