- Home /
Character moving up when animated.
Hi there. I am new to the forum, this is my first question here, started working with Unity sometime ago and I am doing my best at learning it, made some progress but found some dead ends.
I followed the tutorials to set up animations to my character and it worked pretty well, or so I thought.
My animations work when I press the said key, all animations are working, however, something seen to be going wrong.
When I set up my character animated she goes some distance up, I don't really know how to explain it... I made a video just in case.
What happens is that, with animations, she goes up a bit, quite a bit; without animations she stay right in place, no unwanted translations.
It might have something to do with the script I made... It was made just following Unity's site tutorial.
In case it is relevant, my animations are from Mixamo, the Unlimited Mixamo Store (default, not the Mecanim one) and all in .anim file. As they work, I am not sure if the animations are the problem, in the animation preview (which I forgot to record) the character is right on the ground.
I tried to set up a character controller, for what I know it was supposed to make my character hit the ground and stop there, not working...
I also tried (not in the video) to set up RigidBody, but then the character falls like crazy, getting past the ground and going on forever...
Not sure what to look for anymore... Saw a lot of tutorials explaining many stuff, so far, nothing worked.
I was once able to set up the character to be controllabe using the ThirdPersonController (From Lerpz's demo), I could control the character, however, she was still floating and now, for some reason, the controller doesn't work anymore, but that is another thing.
I would really appreciate any tip here. Thanks for your time.
Here's the video showing what is happening: http://www.youtube.com/watch?v=UFSlFF-2dac&feature=youtu.be
OBS: Up (W), Down(S), Left(A), Right(D), Skill(Space), Run(Shift) are Axis I made to have better control over the commands.
This is the script I made:
function Start () {
// Set all animations to loop
animation.wrapMode = WrapMode.Loop;
// except skill
animation["Allie - Default@standing backflip - loop"].wrapMode = WrapMode.Once;
// Put idle and walk into lower layers (The default layer is always 0)
// This will do two things
// - Since backflip and idle/walk are in different layers they will not affect
// each other's playback when calling CrossFade.
// - Since backflip is in a higher layer, the animation will replace idle/walk
// animations when faded in.
animation["Allie - Default@standing backflip - loop"].layer = 1;
// Stop animations that are already playing
//(In case user forgot to disable play automatically)
animation.Stop();
}
function Update () {
// Based on the key pressed,
// play the walk animation
//This handles the forward animation
if (Input.GetAxisRaw ("Up"))
animation.CrossFade ("Allie - Default@female walk - loop");
//This handles the backward animation
if (Input.GetAxisRaw ("Down"))
animation.CrossFade ("Allie - Default@female walk backwards - loop");
//This handles the left animation
if (Input.GetAxisRaw ("Left"))
animation.CrossFade ("Allie - Default@walking strafe to the left - loop");
//This handles the right animation
if (Input.GetAxisRaw ("Right"))
animation.CrossFade ("Allie - Default@walking strafe to the right - loop");
//This handles the skill animation, note that the skill animation is actually a jump
if (Input.GetAxisRaw ("Skill"))
animation.CrossFade ("Allie - Default@standing backflip - loop");
// Here we make sure that the run animation play if we hold down shift either with an animation already playing or not
if(((Input.GetAxisRaw ("Run")) && (Input.GetAxisRaw ("Up"))) || (Input.GetAxisRaw ("Up")) && (Input.GetAxisRaw (("Run"))))
animation.CrossFade ("Allie - Default@female run forward - loop");
if(((Input.GetAxisRaw ("Run")) && (Input.GetAxisRaw ("Down"))) || (Input.GetAxisRaw ("Down")) && (Input.GetAxisRaw (("Run"))))
animation.CrossFade ("Allie - Default@female run backward - loop");
if(((Input.GetAxisRaw ("Run")) && (Input.GetAxisRaw ("Left"))) || (Input.GetAxisRaw ("Left")) && (Input.GetAxisRaw (("Run"))))
animation.CrossFade ("Allie - Default@running strafe to the left - loop");
if(((Input.GetAxisRaw ("Run")) && (Input.GetAxisRaw ("Right"))) || (Input.GetAxisRaw ("Right")) && (Input.GetAxisRaw (("Run"))))
animation.CrossFade ("Allie - Default@running strafe to the right - loop");
//Now we handle the aim idle animation
if(Input.GetAxisRaw ("Aim"))
animation.CrossFade ("Allie - Default@rifle standing aiming idle - loop");
//We can walk while the aim animation is on, so we must check if we are aiming and wanting to walk
if(((Input.GetAxisRaw ("Aim")) && (Input.GetAxisRaw ("Up"))) || (Input.GetAxisRaw ("Up")) && (Input.GetAxisRaw (("Aim"))))
animation.CrossFade ("Allie - Default@walking while aiming rifle - loop");
if(((Input.GetAxisRaw ("Aim")) && (Input.GetAxisRaw ("Down"))) || (Input.GetAxisRaw ("Down")) && (Input.GetAxisRaw (("Aim"))))
animation.CrossFade ("Allie - Default@walking backwards while aiming rifle - loop");
if(((Input.GetAxisRaw ("Aim")) && (Input.GetAxisRaw ("Left"))) || (Input.GetAxisRaw ("Left")) && (Input.GetAxisRaw (("Aim"))))
animation.CrossFade ("Allie - Default@rifle walk strafe left - loop");
if(((Input.GetAxisRaw ("Aim")) && (Input.GetAxisRaw ("Right"))) || (Input.GetAxisRaw ("Right")) && (Input.GetAxisRaw (("Aim"))))
animation.CrossFade ("Allie - Default@rifle walk strafe right - loop");
//We must check if we will fire while aiming
if(((Input.GetAxisRaw ("Aim")) && (Input.GetAxisRaw ("Fire"))) || (Input.GetAxisRaw ("Fire")) && (Input.GetAxisRaw (("Aim"))))
animation.CrossFade ("Allie - Default@firing a rifle while standing - loop");
//Do we want to fire while aiming and walking?
if(((Input.GetAxisRaw ("Aim")) && (Input.GetAxisRaw ("Up")) && (Input.GetAxisRaw ("Fire"))) || (Input.GetAxisRaw ("Up")) && (Input.GetAxisRaw (("Aim")) && (Input.GetAxisRaw ("Fire"))))
animation.CrossFade ("Allie - Default@firing a rifle while standing - loop");
if(((Input.GetAxisRaw ("Aim")) && (Input.GetAxisRaw ("Down")) && (Input.GetAxisRaw ("Fire"))) || (Input.GetAxisRaw ("Down")) && (Input.GetAxisRaw (("Aim")) && (Input.GetAxisRaw ("Fire"))))
animation.CrossFade ("Allie - Default@firing a rifle while standing - loop");
if(((Input.GetAxisRaw ("Aim")) && (Input.GetAxisRaw ("Left")) && (Input.GetAxisRaw ("Fire"))) || (Input.GetAxisRaw ("Left")) && (Input.GetAxisRaw (("Aim")) && (Input.GetAxisRaw ("Fire"))))
animation.CrossFade ("Allie - Default@firing a rifle while standing - loop");
if(((Input.GetAxisRaw ("Aim")) && (Input.GetAxisRaw ("Right")) && (Input.GetAxisRaw ("Fire"))) || (Input.GetAxisRaw ("Right")) && (Input.GetAxisRaw (("Aim")) && (Input.GetAxisRaw ("Fire"))))
animation.CrossFade ("Allie - Default@firing a rifle while standing - loop");
//If nothing is being pressed play the idle animation
if(Input.anyKey == false)
animation.CrossFade ("Allie - Default@standing idle");
}
I had a similar issue, but it had to do with the model. Since you didn't make the model yourself, I can't think of many options. $$anonymous$$y issue was just that in the program I used to make it (blender) I didn't apply the location/rotation/scale, so I just went back and did that.
$$anonymous$$aybe message the creator and ask them?
I believe I found out what happened. Had to do with the pivot being in the center o the character and not the feet, so it was centering to the pivot position in scene... Or so I think.
I imported it back into 3DS $$anonymous$$ax and gave it some work, it is in place now but animations aren't playing propperly. I am still to find out how to solve everything, but I think at least I have a start point now.
Answer by Otaku_Riisu · Jun 03, 2016 at 06:15 AM
You have to disable motion on the Y Axis.
You can do this simply by checking "BAKE IN TO POSE", for Y, in the animation import settings.
This should solve your problem.
Note that generally you leave the "based upon" value simply as "original". (Whichever of the three settings you choose for "based upon", it does not either way affect the "floating upwards" problem described here in this question.)
Note that of course you can not turn off root motion. The actual walking/turning motion (so, on x and z) is the root motion!
Was wondering if you had any idea why this is not available in 2017. I have imported a bunch of fbx animations from $$anonymous$$ixamo, and they are all too high, but I don't have the Root Transformations items.
Is your rig marked as 'Humanoid'? If not the options such as Root Transformation items won't be available (for example if your rig is marked as 'Generic' which I believe is the default import option).