- Home /
Animation Vs Animator
Are Unity replacing the animation system with the animator? Because every time I make a new animation, it builds it through the Animator now. Which seems too complex for my type of animation.
When I say animation, I mean a simple quad animation that has a script attached to it for event calls within specific key frames. I'm using this for a 3D scene GUI element. So theres no avatar, or humanoid involved.
If this is the case, then how do I control the animator player now? Before, for the animation, I would go animation.Stop, or animation.Play.
This doesn't work for the animator. I took a look at the script reference, and I found this:
Animator.StopPlayback
But that doesn't actually seem to do anything.
Answer by Dizmiester · Mar 03, 2014 at 01:09 PM
Setting animator variables or parameters. Then in the Animator you set the state changes in relation to those variables and in your script you modify those variables.
Say you want a walk jog and run animation, then you would set a groundSpeed parameter.
In the Animator set a state for walk, jog and run and set the relation to if(groundSpeed > 0 && groundSpeed < maxWalkSpeed ) loop the walk animation and the same for jog and run etc.
Make sure you set parameters for an idle animation.
update the groundSpeed parameter from your velocity calculations and the animator should change the state according to the value of groundSpeed.
You can also just play states from your code using (where anim is a variable of type : Animator, and set to the Animator component) anim.Play("theNameOfYourState");
Note: Animator.Play() will throw up an error because you are saying "the Class of Animator".Play() rather than referencing an instance of the Animator class (ie: the Animator component attached to your GObject)
Okay, but isn't this system a bit of an over kill if your doing, for example an animation for a 3D GUI? Where it needs to be controlled by script, but also only needs to use the simple animation transforms.
I cant get my head around this, I've made a full animation clip within the Animation window. I've also added event key frames that call functions within the attached script.
Firstly, I don't wont to play the entire animation (the whole animation contain different states of my 3D scene GUI).
What I would normally do is place an event key frame at the end of one state within the animation, and within that function, have animation.Stop();. But this was with the old animation system, which I cant use for this new Animator. So I tried anim.StopPlayback(); (to prevent it continuing through the rest of the animation), but nothing happens (although it is calling the function as it prints).
Ok I see, you could try setting the animations as Legacy in the inspector. That would then allow you to control them as you did before. Not 100% sure on GUI animations. This may mean you don'tuse the Animator at all but make the animations in blender or such.
I still dont get it, you can put your animations in the animation component, and then just call them in your script: If(Pressed$$anonymous$$ey"W" && !pressedkey(leftshift)) { animation.play"walk" } if(pressedkeyW&≤ftshift) { animation.play"run" } simple as that as I can see, why do I need to go to the animator, make variables, point to states etc etc etc if I can just say, push button play this and thats it, simple as possible.
$$anonymous$$y understanding is that the animator is a GUI designer, so you can see do it graphically ins$$anonymous$$d of typing and making a script.
Answer by Triqy · Mar 05, 2014 at 01:47 AM
I think you have to set up the animator as a generic type when setting up your animator. Then your have to split your key frames up on your objects and set them up individually in the inspector. Like 0-30 walk, 31-61 run/ whatever. The in your script that you have on your object would be something like animator.Play("walk"); or animator.Play("run");
////// help help public AnimationClip animclip;
animator.animation.AddClip(animclip,"runmm");
Your answer
Follow this Question
Related Questions
Animations - Can you cut them? 2 Answers
How do I add NPCs? 2 Answers
2D Animation does not start 1 Answer
Problem with GUI animation transitioning. 1 Answer
GUI button is moving/disappearing when animation is played 0 Answers