Animator, animation and proportional scaling

Hello,

Recently I began learning how to use unity and something that is messing up with my brain is animation.
I learned how to use animator, but I don’t know if some features don’t exit or it’s just me not knowing them and not finding anything about them anywhere.

The most recent one to fry my brain is how to make animations be more “universal” by using proportional scaling.
By that, I will tell the problem I have as example.

I have a 3D menu with 3D buttons and everything. Every button needs to have its own “Hovering” animation (that consists on scaling), but different buttons have different sizes, and in order NOT to make one hovering animation for EACH button with different size, I created an animation via script that doesn’t use absolute values as animations require, but proportions.

So instead of making an animation that changes the scale of a button from:

(1,1,1) → (2,2,2)

I made a script that doubles the previous size of the button, this way I can use this script with every button.

I was happy.

But then the fire nation came and… I had a problem with one of the menu animations not disabling box colliders in time and activating the button animation script while the menu was rotating and making the script animations be kind of “cut” while running and… well… I’m trying to find another approach to this problem.

So, my main question is this one:

Is there a way to make animations (the ones compatible with animators) deal with its variables (position,scale and rotation mainly) proportionally instead of with absolute values?

If not, what is the best approach to deal with 3D menus and buttons using the animator?

Thank you for the patience and for any useful information.

Hi - the best way to do this is simply have an empty game object as a parent node for the 3D object you wish to scale proportionally. I just did a quick test and if you do the following it should work for you:

Create a cube > Open the animation pane > Add curve > Create a named clip > Scrub to frame x > cube : Scale > Scale.x > adjust (this creates the controller automatically)

Then create your new cube of a different size > create and name an empty game object (e.g. CubeParent) and parent the new cube > add Component > Animator to the CubeParent and in the animator drag in the first animation clip you created. It should now scale the cube proportionally.