Unity 3D Model Y Translation when Switching animations - animation

I made an animator for my Player Character, I have 2 differents animations.
When I play only one, nothing, it's cool, the character is doing the animation.
OwnAnimator.SetBool("running", true);
But when I have multiple animation (2), in my AnimatorController, the player goes under the floor instantly at the runtime O_O.
Please someone can help me ? :)

What is your second animation? Since animations can affect the transform position it is possible that your animation changes the Y-axis of the transform.

Related

Position of player changes when the attack animation starts - unity

So I did an attack animation in the program Aseprite and everything was fine with the animation, but when I put in inside the animator in unity the character changes position.
Here's the images, first one is a gif with the animation running as I want, and then the before and after of the animation in Unity.
I know it's small but I hope you can see
This is because it's setting the center point at the location, and the gif is wider than the standard player image, you will need to offset to compensate.
So I just sliced the sprites again but with the pivot to the left instead of center, and then adjusted the Collider. It seems to work. Not sure if it's the perfect way though.

How to change rigs spine rotation in unity3d, using camera rotation?

I have a rigged 3d model of a person with animations that i made. It is a player model in a first person shooter. I want this model to "bow", when looking down or do the opposite, when looking up. To achieve this, i decided, instead of making an animation for each degree the player might decide looking at, to rotate models spine, depending on the angle of the camera. In scene view, i can easily change rotation value and get the results i want, however, when game is running, those parameters seem to be "locked" and no matter what script i tried, i cant seem to change the rotation value. I figured, perhaps, when animation is playing, i cant change things it effects, so made a body mask to excluded torso from animations and spines rotation was still locked away from me. Is there a way to rotate models spine, when its doing its normal, lets say, idle, animation? is there actually another easy way to achieve this?
You have to update in LateUpdate(). Unity's animator does it's changes to the transform in Update(). By doing it in LateUpdate() it will be handled after the animation has made it's changes.

Flip 2D asymmetric animation in Unity3D

I want to flip my 2D character (asymmetric) from right to left using the animator in Unity3D
I have the sprite sheet with both left and right sprites and I did a controller with the animations facing right, now I need to flip the animations to the other side
Done:
Sprite sheet with both animations left and right
Animation controller with animations facing right
Goal:
Make my character change animations facig right to facing left and viceversa
I'm aware of the code to change the local scale, but I'm not interested in changing scale, I'm looking for a way to flip the animation
Thanks
You can flip the animations changing the x/y scale from positive to negative. Why you are not interest in changing the scale? You can flip the animations with this method.
Sorry for my English and good luck.

Unity2D - Player relative animation positioning

I'm making a 2D platformer and I've come across a really annoying problem where if I move my player character GameObject to another location on the scene, my player becomes stuck and the game spazzes out, jumping from the players original location and the position I moved it to.
My player character is made up of many parts, each a separate GameObject. I know the problem is definitely in my animation, because if I disable the animator component, the problem goes away, just I don't have my animations anymore. I believe the problem may be in the player character's Idle Animation and it's position property. There is no script attached where his starting location is hard coded.
How can I make the child Gameobjects move relative to the parent Player GameObject? I cannot move the player in the scene from its original location without the game glitching up.
Here are some screenshots
[Player and it's parts in Hierarchy]http://i67.tinypic.com/bdlc1j.png
[Idle Animation]http://i64.tinypic.com/2gtp99x.png
[Player's original Location, he works if starting here] http://i66.tinypic.com/261jb6c.png
[Player is Moved, game bugs out] http://i67.tinypic.com/292a2c3.png
Try to disable "Apply Root Motion" flag in the Animator component.
The problem should be related to the fact that the animation changes the position values
My guess is that you have animated the different parts by moving then around in the editor and recording that. This meas that the animation is keeping track of the original position at which you did the animation. Try deleting those parts from the animation.
I couldn't fix the spazzy-jittering problem that occurs when I move the player character to another position on the scene, but I did find a way around it. The problem definitely lied within the Animator component and the gameObject's Rigidbody2d.
Instead of moving the player to another position, I instead made a 'Spawn Point' which the player starts from when first playing the scene, and that was able to be moved freely around. Pretty much:
void start(){
transform.position = spawnPoint.transform.position;
}

How to properly flip 2D character with new Unity4.3 2D framework? (Rotation of gameobjects during animation)

i'm already checked official Unity 4.3 example project, and there they use
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
This works pretty well, but. But i'm encountered an trouble, not sure this trouble with this Flip or with something else.
I'm use Animator to animate my characters, i have Attack animation, which in addition to the sprite animation also move character's Hand, which can carry the Weapon. Problem is when i flip the character to opposite direction Hand will move wrong (not as planned), which is wrong. (video below will be more descriptive)
I discovered that this problem occure only if i modify the Hand's rotation in animation, so if i works only with .position this works well, but i need the rotation!
What is best way to get this work?
Here the youtube video: http://youtu.be/qpMK2gRgDz8
At video i show animation without rotation uses, hand moves correct. But next i show it with rotation, as you can see when character turned right this works well, but when left, its completely wrong.
What you want to do cannot be done with scaling cause scaling does not change the rotation of the object and so the forward vector remains the same. You must create double sided objects and just rorate them 180 degrees or you can ue a shader that draws a polygon even when its normal vector is against the camera.

Resources