- Home /
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.
Answer by OllyNicholson · Sep 11, 2014 at 04:04 PM
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.
$$anonymous$$an, that's exactly what I needed! I just point out that in order to make this work, you $$anonymous$$UST make the empty parent have the same size as the object where the animation was created when the animation begins.
So if you want every object to go from size 2 to 1, the parent must have size 2 in order to reduce its child\children size by half.
I just hoped there was a more intuitive way to do this via the animation panel and without creating so many empty objects. Even though they are empty, they still "waste" process.
Thank you for your time and answer. I'd upvote, but don't have 15 reputation yet, when I gather enough, I'll upvote your answer!
Your answer
Follow this Question
Related Questions
How to scale the changes done to a transform in an Animation on various objects? 1 Answer
2D Animation does not start 1 Answer
An empty idle animation overwrites values set through the FixedUpdate code 0 Answers
Scale reverts to 1 as soon as it is changed 0 Answers
Play an animation forwards and backwards without losing its progress. 0 Answers