Unity 2D: how to play 2 animations at once? - unity3d

so recently I started working with Unity animator, pretty cool, but got an issue.
I want to play "walk" animation and whenever preson gets a gun play another "hold" animation.
I tried to make 2 layers with usual walking and beneath it gun holding animation, but it just overrides with gun holding animation.
Any ideas?
Edit: screenies

As KinyL states, you need to add an Avatar Mask to the upper body layer. In the Mask, uncheck the lower body elements and you'll be good to go.

Related

How to make an object follow the movements of an animated object in Unity?

So I've animated my spaceship. With it's previous rigid form I've got a particle system coming out of it's wings. Now that it's animated, I still want those particles to follow all of it's wings movements, but the particles don't move along with the animations, even being parented with the gameobject's wings, showcase video, 19seconds: https://youtu.be/XJNjT4s4X6I
How can I make those particles move along with it's wings movements? Thanks
I would try to parent them with the bone of the armature, I don't remember if it worked for me though, but what I did is to add an empty in the modeling program to follow the animation and export it, so I can parent it to the things I needed, for you It would be the Particle System.

Collider is not following character animation

I have a combat animation in my game and I want my hitbox to follow the animation. I have tried using the record feature, but it has not been working. Is there any other ways I can have my problem fixed.
Colliders get animated with the animation itself and moves accordingly. Make sure that the object you are animating has a collider on itself not on its parent.

Unity Animation - Shifting Position Unexpectedly

I'm learning Unity right now, and I want to animate a sprite of Mario running.
I found a spritesheet and have cut out 3 images.
I select my Mario game object and create a new animation
In the animation window, I put in 3 spites at the times I want to animation the run
When I press play, Mario is running, however he is also shifting position a little bit in the X direction but then resetting as the animation loops.
Why would my Mario object be shifting a little bit as part of the animation cycle? Where would I look to see an attached property or behavior that is causing him to do this? Maybe I moved the object while I had record on? I deleted all the associated animation objects and recreated them but Mario is still moving.
I figured it out. I had a pivot point created on a single frame of the sprites. This would screw it up.

How can I make the last sprite in an animation play for more than 1 frame?

I have a 2D sprite animation of a waving flag, which I'm playing in a loop.
The problem I'm having is that the Unity Animation Editor is making the last sprite of my animation play for only one frame, whereas I have every other sprite playing for several frames. So when the animation loops back to the beginning, the last sprite transition doesn't look smooth because the last sprite is visible for fewer frames than every other sprite.
Is there a way to increase the number of frames that my last sprite plays for in the Animation Editor? Or is there a different way to handle this problem?
Here's my animation. I circled where the problem is.
Click on the diamond above 0:00 and copy. Then go to 0:24 and paste it. First and last sprites look the same but if not that is the reason for this and what I propose must work.
Note: BugFinder's solution works as well:
adding a keyframe at the end without changing anything is not the same as an empty one..... The sprite value remains the last one

Unity - How to disable animation interpolation / animation curves?

I'm trying to animate a hierarchy of 2D sprites (essentially body parts) by explicitly setting sprite positions at various key frames throughout a given animation clip. Unfortunately, Unity is implicitly changing all of the sprite positions using interpolation between key frames. This causes the sprites to look like they're sliding around rather than immediately transitioning into their correct positions.
So far I've come up with 2 rather poor solutions:
I could potentially create separate animation clips for each combination of sprite positions and transition
between them using mecanim parameters or in
code, but this seems tedious at best and inefficient at worst.
I could add more keyframes (either in the animator tab or in the
curves screen) that maintain each sprite position until just before
they need to be updated. This is a slightly better option but also
extremely tedious.
Is there any way to tell Unity to disable animation interpolation at least as far as positions are concerned? Thanks.
In the current version of Unity (2019.3), go to curves view, right click a keyframe node and select Left Tangent -> Constant. You may want to use Right Tangent depending on the use case. That should give you the instant change you're looking for.
Have you checked Brackeys video of animating 2D in Unity? Maybe it can help you :)
The following link is his video on how to animate 2D sprites.
https://www.youtube.com/watch?v=whzomFgjT50
Alright, I've come to the unfortunate conclusion that Unity forces you to use curves when dealing with animation keyframes and that you need to add an extra set of keyframes for abrupt shifts in animation.