Problem using mecanim with top down movement

Hello. I’ve been using mecanim and I’m wondering a couple of things. In the old animation system, I could get moving around with the right animation with no problems. However, going with mecanim, I’ve been having a lot of trouble trying to get the animation working with actually moving things around.

The biggest problem is that I’m using a top down camera and movement. The player is moving around, but sliding all over the place. Not only that, but the running/walking animation is having trouble because “speed” and “distance” don’t seem to be working in this setup.

Here’s my code:


//This code was clipped from another section of my code.  I just moved it here so you guys could see what was going on.

float cordX = Input.GetAxis("Horizontal");
float cordZ = Input.GetAxis("Vertical");
direction = new Vector3(cordX, 0, cordZ);

myBody.anim.SetFloat("speed", direction.x);
myBody.anim.SetFloat("direction", direction.z);

if (direction != Vector3.zero) {
				
    if (Vector3.Angle(myBody.transform.forward, direction) > 179) {
					
    direction = myBody.transform.TransformDirection(new Vector3(.01f, 0, -1));
					
    }

    myBody.transform.LookAt(myBody.transform.position + direction);
    direction.y -= myBody.gravity * Time.deltaTime;
    CharacterMove.Move(direction * myBody.bodySpeed * Time.deltaTime);

				
}

Not sure why my character slides around, but perhaps you guys can provide some insight. I’ll be honest and say that I’m only recently getting into mecanim. I could be doing something wrong.

Also, I may be setting up speed wrong in the blend tree. Thanks for the assistance.

Try un-checking “has exit time” in all your transitions to get rid of the sliding problem.

I was having a similar issue just minutes ago.


Make sure you have an Avatar set on your Animator component that’s attached to your player/character. Also make sure to set the correct Avatar.



This fixed it for me, I hope it helps you.