Unity Involve Instatiated objects in Animation - animation

In the 2d-game the player should be able to shovel some dirt when he stands on a dirtpile. player allready has the animation for that, but the shovel has to be generated.
So i generate the shovel and trigger the animation. but the animator doesn't animate the shovel. Any solutions?

Why does the shovel need to be generated? If you just want it to be visible at certain times, you can go ahead and animate it normally in the Editor, then set it to inactive when you don't want it to be there.

Ok, so i found the answer my self. before Triggering the animation event Rebind the Animator.
Animator anim = player.GetComponent<Animator>();
anim.Rebind();

Related

Trying to add my animation to my idle state, but it just keeps saying "None(Motion)"

I have pulled the animation to the Motion tab both by dragging and trough the select motion search function but neither makes the animation stick to my idle state. Can someone give me a pointer to what im doing wrong?
One reason could be that the animations are marked as legacy.
Select one or many animation, in the inspector next to the lock, right click, then Debug. Untick the Legacy. No need to save or else.
The animation which you're trying to set is for another model!
You should use an animation that is for the model.
Or if you insist on using that animation select animation from assets and do a "Control + D" to duplicate it and use new one.
Use the Animator, not the animation controller. I made this mistake when I was following a tutorial. This is only relevant if you are animating .anim files within unity itself. Animation controller is the way to go if you import animations for your specific model.

Unity apply idle animation to model

I created a model in Blender and posed it the way I want it to look. The character will never move and no animations will ever change.
I exported the character with animations to an FBX and imported it into Unity 3D. After dropping the character into the scene, the character's pose is back to the default take.
How can I force the character to use the pose that I want? Do I have to do it in script or is there a setting that I can change to make it play the idle animation at all times?
Putting your model in the scene will not invoke idle animation, animation and rendering is two separate thing. To always play a certain animation on a model you have three option -
1. Via Legacy Animation -
Select you model in the scene, remove the default Animator component and add a new Animation component. (Animator and Animation are two different component type.) It has an option of selecting an animation clip. Drop your animation clip there and choose 'Play Automatically'.
2. Via Script -
You can add Animation component, attach multiple animation and select which one to play via script too.
You can also do this for meca-anim way which is explained in the next point.
3. Via Meca-Anime
Every model has a default Animator component. It needs an animation controller object to run. Create an animation controller (Click on create button in project view). Attach the controller to the Animator component. Double click on the controller to open Animator view. Drop your clip there and make it as default. The default animation plays automatically now. Using Meca-anime has many advantage over legacy way, which is beyond the scope of this answer. Check the following link instead -
Mecanim vs Legacy Animation

Unity2d Animation won't loop

Using unity 4.3.4f1.
I started a new project with only one game object on wich I added an animation with 4 sprites. I choosed "Always Animate" from the Animator configuration oon the game object.
When I run the game, the animation play just one time. I see in the animator panel that my animation is replayed again and again because I only have one state. However, Animation won't loop when running the game.
Anyone knows why ?

Cocos2d for iPhone: i have a delay with with animation (fps collapses)

I've this problem:
in my game, when I tap a sprite, an animation in called. This animation is stored inside a singleton class (called Animation) that is inizialized in the didFinischLaunching method.
When I need for an action i use this code:
[self runAction:[[Animation sharedAnimation] animationName]];
On the device when I tap the sprite for the first time, occurs the following issues (one and only at the first tap):
There is a delay from the moment when I tap the sprite and the moment that the animation really starts;
In this interval (delay) the frame count collapses to 10fps (in some case even to 6fps)
This issues there aren't when I tap the same sprite for a second, third, etc times.
Ideas ??
Thanks very much!
Do you alloc the spriteframes in your animation init method?
If so, that's why.
Good luck!

How can I trigger Core Animation on an animator proxy during a call to resizeSubviewsWithOldSize?

I have some NSViews that I'm putting in one of two layouts depending on the size of my window.
I'm adjusting the layout when the relevant superview receives the resizeSubviewsWithOldSize method.
This works, but I'd like to animate the change. So naturally I tried calling the animator proxy when I set the new frames, but the animation won't run while the user is still dragging. If I release the mouse before the animation is scheduled to be done I can see the tail end of the animation, but nothing until then. I tried making sure kCATransactionDisableActions was set to NO, but that didn't help.
Is it possible to start a new animation and actually have it run during the resize?
I don't think you can do this easily because CA's animations are run via a timer and the timer won't fire during the runloop modes that are active while the user is dragging.
If you can control the runloop as the user is dragging, play around with the runloop modes. That'll make it work. I don't think you can change it on the CA side.
This really isn't an answer, but I would advise against animating anything while dragging to resize a window. The screen is already animating (from the window moving) - further animations are likely going to be visually confusing and extraneous.
CoreAnimation effects are best used to move from one known state to another - for example, when a preference window is resizing to accompany a new pane's contents, and you know both the old and new sizes, or when you are fading an object in or out (or both). Doing animation while the window is resizing is going to be visually confusing and make it harder for the user to focus on getting the size of the window where they want it to be.

Resources