Using Integer as Animator Parameter- App Dev Series 17

Objective: creating animation transition with integer.

In this tutorial, we would use integer as the parameter of animation transition.

Animator overview

In this example, we would use a horse anatomy animation. Within the animator, we would need to make it could switch between body, muscle, and bone, these 3 animation.

And to present how to make a transition base on parameter integer, I already finished setting the animation flow like this:

Apply integer as parameter to transition

In order to make a smooth transition without using any specific parameter like trigger, we need to numbers each animation as its index.

That is the basic of how we use integer as the parameter in Animator.

And now, let’s add an int parameter to Animator.

With this parameter, we can assign it to all the transitions in this Animator.
Follow the animation of its index number as we numbered in the previous screenshot, and assign the integer to its transition.
The integer should be the same as index if towards to it.

With this setting, we have already created an order of animation flow.
Now we can call it in the script. Let’s control the animation from UI buttons.

Creating UI

Create 2 buttons called “Next” and “Previous”. Then create a new script called “UIManager” and assign it to canvas.

Inside UIManager, create 2 public methods: “NextAnim” and “PreviousAnim”. Then create a public variable of Animator, and an integer variable to store the current input integer.

As the rules of animation flow we created, we can easily control the animation with the following code:

And that would make a perfect animation control. Then we need to assign it to both buttons and here is how it looks like when run it in mobile:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store