Comments
It's always a good idea to retrieve a reference to the Animator component inside Awake, and then store its value in a private class variable, which can be used anywhere throughout the class. An alternative is to call the GetComponent function wherever you need a reference, but this is comparatively expensive computationally, so avoid it.
The Animator component offers us a method to directly access the SetInt Int parameter. This function accepts two arguments: the first identifies which Int parameter must be set (we can have multiple parameters), and the second is the value itself, which should be assigned to the parameter. Now, there are two versions of this method, and each differs by how the Int parameter is named. We can name ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access