Unity Animation - Shifting Position Unexpectedly - unity3d

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.

Related

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

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.

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

Animation not working on an instantiated prefab (weapon)

So i'm working on this project and i'm using it to finally learn how to animate in 3D (taking a small break from coding hehe)
So here i am faced with a problem and i have no idea what i did wrong. First let me explain how everything works.
So the Animator is attached to the player, and the player obviously has a structure of legs arms...etc
everything inside the player is being animated by this animator.
So i have a weapon (a wooden sword) that has it's pivot attached to it's bottom (in case it helps to know)
i'm animating it from that pivot point, which happens to be the parent to which the sword model is a child to.
When i hit the V key the weapon gets instantiated in the player's hand (which is an empty gameobject) and when i press the F key the player attack and activates a trigger in the animation that starts the attack animation.
But the animation is not working properly. more precisely the key frames of the weapon are not being player(as you can see in the video all the rotation axes give the coordinates of 0 0 0 throughout all the animation.
But, ...and this is where the strange things start!... when i manually go through each second to play the animation and see what's happening, you can see that those coordinates start to change and it shows the animation exactly as it's supposed to be. then when i switch back to idle state so that i can start moving around the player normally. when i hit the F key to attack the correct animation is player and no problem happens... Magic? i don't think so... :p
what do you think? what could be causing this problem.
Who's up to solve my riddle :cool:
Seriously guys what's going on here, i need help.o_O
Thank you all ;)
The Video : HERE
In general: You are using an ALPHA version 2019.3.0a4 ... in short don't.
As any alpha version it is like to have some bugs .. especially since you are not even using the latest instance of the alpha which afaik would be 2019.3.0a12!
2019.3.0b1 is actually even already in BETA state a lot of former bugs should be fixed there - but it is still a beta release meaning it is not ready for production.
So in general don't even use the beta. Rather stick to the latest stable release version which would now be 2019.2.3f1
There is not directly listed one relating to the animator not finding a certain object at first and then not animating it .. but as said alpha version are likely to have bugs. Also since it is an instantiated prefab the original instance will be gone .. then by name it gets re-assigned by the animator so the main issue might be that you instantiate it in the first place instead of just having it already from the beginning.
You should consider only using the parent/pivot object of that sword and not animate the sword itself at all. Simply spawn it as a child of the animated pivot and you should be fine,

Problem animating the position of a GameObject in Unity while moving it

I am working on moving a Cube across the screen when I press an arrow and display two different animations depending on if it is moving or idle. I used a very basic translation to do this when I press the right arrow. I have two different animation states that work fine independently. One spins the cube when it is “idle” and the other makes to bounce up down in the “right” state. Both are 1 second animations. The idle animation spins the cube 360 degrees, and the right animation will move the cube up 1 unit then back down to its original position. Everything works well by itself. I included an image for the states for the animation.
Cube Animation States
In order to get the movement working with the animations I made an empty GameObject and made the cube a child if it. When the cube is idle it spins, and when I press right it moves and bounces up and down. The problem is when I release the right arrow the cube snaps back to its original position from the start of the last bounce animation. If I hold right for 10 seconds, and release it will only snap back to the beginning of the most recent iteration of the bouncing animation (not to when I started pressing right).
Does anyone know why this would happen? I tried changing some of the settings for the transitions, but it doesn’t seem like that is the problem.
Can you check that your idle animation modifying its position in any case.
First, you can't move the game object with animation.
you can have the rotate animation in the cube but not the translating part.
Because when the animations switch between the states the object will be moved to its original position.
solution:
-Create a script and attach the script to that game object.
-use translate functions to move the object

Unity 5.3.8 Animator - Glitch?

I created a bunch of non-AI animations for enemies that do basic back.forth or up/down motions. Everything was working perfect until I started working on the Boss of the level. The boss has his own tag "Boss" and enemies have their own tag as well. Anyway, the problem is when I click start, every enemy leaves the game board. I can see them animated above the game board still doing their routines.
Any clue as to why this happened and how to fix it? I'd really, really hate to have to scrap all the enemies and start from scratch...
I used the Animation tool inside unity.
Extra Note: I created an EMPTY and moved all of my enemies into that Empty object to clean the hierarchy panel up. The animations were fine before this.
************** Currently Resolved **************
Whew! Okay, so apparently Unity doesn't like it when you move your animated stuff into an empty AFTER being animated. I FIXED them by simply removing them from the EMPTY that I had placed them in. However, I'd still like to know why this is. So any useful resources, links, manuals, personal insight/observations or anywhere I can read up on this would be appreciated!
Here is an explanation what happened:
The moment you dragged them all into the empty GameObject I guess this object probably wasn't placed on 0,0,0 in the Scene.
So Unity automatically changed all the local position values of your enemy items to fit the current position offset to the empty object.
Result: In the editmode they don't change their actual global position in the scene but their local position. This is supposed to happen if you just want to organize stuff.
However, now when you start the game and the animations are played, the animators change all the local positions to whatever is stored in your animations.
Result: all objects jump back to their original localPosition which had an offset to the empty GameObject.
To solve this make sure the empty GameObject is at position 0,0,0 and optimally has rotation 0,0,0 and scale 1,1,1 before you drag anything into it.
Easiest way to achieve that is by clicking reset in the empty objects Transform component before starting to drag stuff into it.