animation not playing unity - animation

This appears to be such a common problem, that finding answer to my specific case is near impossible, because of the amount of noise in google or forum searches.
I have imported object to unity from blender. This objects had smaller objects inside it. Those smaller objects have animation on them, which was created in unity. If I open the animation window (Window->Animation) and press play - I can see correct movement of an object. Animation is set to play automatically in inspector, culling type is always animate. If I play the game however, animation does not play. Why?

add the animation to the main object, then animate the smaller object...
you have to put animation component to main object, then animate the small part...
it is important...
it should work

I Could not find any unity inspector based answer. For now, the best option I have is to create new script, and in update() check if the animation is playing. If not, play it. Very inefficient, so to whoever might stumble upon this post in the future, I suggest you try to add this.animation.play() in setting up part of the script.

I know it's kinda late, but this is for others having this same issue.
Animations in Unity have types (2 of which I know).
Type 1 can be attached to an object using the Animation Component.
Type 2 can only be used in Animators (Mechanim).
Animations imported with FBX files are type 2 (and as far as I know, animation type in FBX files can NOT be changed), so they will usually not work when attached directly to an object with "Animation". They should be used with Animators and Animator Controllers. Just create a New Controller and add the animation. It will become the default animation state and play automatically.
If you want it to loop, click on the FBX asset, and in the Animation tab, choose Loop Time and click Apply.

Related

Unity 2D animation seems blocked

I have an animation in Unity, its 2D, made from Sprites.
My animation is blocked, I mean, I can't add a new sprite, click play button, or add a new Property.
In order to animate an object in Unity you have to have a valid object selected, that is to say, the object can be animated.
This is typically a game object that is selected in the hierarchy.
Without this, how does the animation window know what it can and can't animate? That is the way that properties are animated in Unity, it needs to know what it is supposed to be animating, the valid object tells it what can be animated. Without this knowledge, the animation window will lock down certain features, adding keys and playing the animation.
In your case, select the game object that you want to have animated and, if you have a valid animator controller in place, the animation window will set itself up with all the necessary bits and pieces, namely the animation clips. Then you can animate to your hearts content.
Here's the animation window reference:
https://docs.unity3d.com/Manual/animeditor-UsingAnimationEditor.html
Hopefully this answers your question.

What is the better form to animate on Unity 3D?

I would like animate a object similar 3D sequence diagram using Unity 3D. I donĀ“t know what is better form to animate, if Animation or Animator...
So, I do a preview on Power Point https://youtu.be/tgfPIT47xGY
Animation vs Animator:
The Animation component is an old component used for animation in our legacy animation system. It remains in Unity for backwards compatibility but you should not use it for new projects. Use the up-to-date Animator component instead. SOURCE
Use the Animation Editor View for this.
To animate Game Objects in Unity, the object or objects need an Animator Component attached. This Animator Component must reference an Animator Controller, which in turn contains references to one or more Animation Clips.
When using the Animation View to begin animating a GameObject in Unity, these items will be automatically created, attached and set-up for you. SOURCE
Though slumtrimpet is obviously right, I can't see why you might need animations to create something like the video you shown. Why don't just use sequential instantiates with the help of coroutines or simple timers?

Unity 2D Animator, confusion on parameters and transitions for platform 2d character

I am new to designing games and have been having trouble for the past couple of days with the animator. I have downloaded a free asset off the Unity store that included a free sprite character and also its animations for idle, walk, run, and jump. My issue is when I go to use this asset pack in my game, I can not for the life of me figure out how to transition between idle->walk, and any state->jump. I believe it has to do with no parameters being set up, as I want the walk animation to occur when my character is moving. The issue is that it seems to be stuck in idle mode. In the animator the transitions are set up, but I can not figure out how to let the animator know when I am moving, and when I am actually idle. How can I connect my characters movement scripts to be used in conjunction with the animation? Do I need to write a new script, that uses new parameters I make in the animator, or am I completely missing something? Again I am very new at this, so I apologize if this is a dumb question but I cannot figure it out. All the videos I have watched only show how to build the animations and put them into the animator, and nothing about the scripts or parameters in specific. Thank you!
Look at the animation transition requirements, then set the required values. For example:
Animator anim = obj.GetComponent<Animator>();
anim.SetTrigger("running");
or
anim.SetFloat("speed", 2);
or
anim.SetBool("running", true);
One small thing that could be going wrong: If you somehow have a reference to the prefab instead of the instantiated object in your scene, it will not work. And to be sure it's not working, play the game, find the object with the Animator in the Hierarchy, click it, and open the Animator window. You can see which state is active.
If this doesn't help, can you describe the transitions in more detail?

Unity Animation not working on different scene

I'm working on a menu scene where the options come down from top, so I tried to use Unity simple Animator. The problem is the animation won't work. The weird part is, when I tried the same thing on my game scene the animation works.
-I've checked that the animation is attached to the object
-Culling type is Always Animate
-I've also added a script and tried to force the animation with no results.
Why doesn't the animation not working anything other than the main scene? Do I need to trigger something for it to work?
Things you could check:
Make sure you are using the same kind of component in both scenes. Animator is different from Animation.
If you have an Animator component make sure you have an the right Animation Controller attached to it.
If you have an Animation component make sure that the Animation field is set and holds your animation file and Animations is set too and holds the list of possible animations of your (UI) object.
Even though they have the same extension, .anim files created when an Animation component is attached are different from .anim files created when an Animator component is attached so if you try to play an Animator .anim it won't play with an Animation component.
Is your Animation set to play automatically? If not, are you giving the animation.Play() command somewhere in your code?

Unity 4.3 Play animation on hit

I'm currently building a 2d platformer and encountered a few problems.
My player has a script so that when the player hits a cube with a rigid body, the cube can be pushed. When the character pushes the object, the regular walking animation is displayed.
I want to play the pushing animation at that moment but cant seem to fix it. I read a lot of topics on the internet about the difference between unity new Animator editor and the older versions.
Is there a simple way to trigger the animation on hit, and how do I have to add it in the Animator? Also with witch states should it be connected?
Found it on google, maybe it will help
http://unity3d.com/learn/tutorials/modules/beginner/2d/2d-overview
He uses a Layer for the animation of the cannon so he animates regardless of the body animation.

Resources