CodeMonkey
CodeMonkey

Reputation: 1835

Animator's Integer Updating for One but not Another

I have a left hand and a right hand with animators. I made the left controller, copied it, and renamed it as right then modified the stages for right-hand animations as opposed to left hand animations. I then use the exact same code that is attached to both a right hand and a left hand gameObject that says to get the animator and set the "HandPosition" integer of the animator to an enumerated value of "open" or "shield" etc. The right hand's "Hand Position" will update the value, but the left hand's will not. It forever remains zero. The Animator on each hand clearly has the "Controller" value set respectively to Left and Right versions of the animator controller. Why the heck would one integer update but not the other? They're copied, running the same code, and it's not even erroring. I can run the following code and one hand will show it update while the other will say it's updating to "2" and then the new value is still "0". I'm out of ideas!

Debug.Log("Setting " + hand + " to position " + handPosition + "(" + (int)handPosition + ")");
animator.SetInteger("HandPosition", (int)handPosition);
Debug.Log("New position is " + animator.GetInteger("HandPosition"));

enter image description here

Upvotes: 0

Views: 203

Answers (1)

CodeMonkey
CodeMonkey

Reputation: 1835

Apparently it does not error when you give a bogus integer name or even when a controller is not present in the animator script to even attempt grabbing an integer name. Interesting "feature"... So, in my case, there was apparently a second animator on my object that I was not aware of and the code was grabbing that one instead of the one I had set up correctly and silently failed to find what I was looking for.

Upvotes: 0

Related Questions