When the mouse is down, I want to invert the id 0 param, which is a bool. Can I do this, or are animation params write-only? Do I need to keep track of it externally?
In my case, I need Animator.GetBool.
However, I’m unsure what
id should be. Attempting to use
0 (assuming that the list of params is a zero-indexed list) results in the error:
Parameter 'Hash 0' does not exist.
It looks like AnimatorControllerParameter isn’t included in the wrapper code generation. We’ll have to add it and build a new Client and SDK.
I did get it working, but things are still wonk. I’m trying to determine how things are wonk, and will document it.
Just a FYI, the difference between the string and int args of Animator Get Bool – the int arg is the NameHash. You can get the name hash by calling Animator.StringToHash (not sure if this is exposed in Udon) during Start and then save the result (int). The int arg version is a more efficient lookup, of course.
The wonky-ness could be due to the OnMouseDown event getting called continuously while the mouse is pressed. Unless you can press the mouse within a single frame, it will toggle an unknown amount, so the parameter will be left in a random state.
There’s also OnMouseUpAsButton which would only trigger once (i think), but the behaviour is slightly different since you have to complete the click to fire it.