Character rolling around instead of walking forward,Character rolls instead of just moving forward
Hello,
i just downloaded a simple Character (Ip_guy) and set up some animation for it. I used this tutorial to do this: https://www.youtube.com/watch?v=wf6vtCgLk6w. This animation clipping stuff works very well but I have some problem with moving my character. I followed the instruction in the tutorial to write a StateMachineBehavior. When I want to walk forward with my character it rolls around instead just walking straight forward. The walk animation plays well but my character is rolling around.
Can anyone help me please with this? Here is my code of my StateMachineBehavior:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Locomotion_SMB : StateMachineBehaviour {
public float damping = 0.15f;
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector2 input = new Vector2(horizontal, vertical).normalized;
animator.SetFloat("Horizontal", input.x, damping, Time.deltaTime);
animator.SetFloat("Vertical", input.y, damping, Time.deltaTime);
}
}
I added a rigidbody component and a box collider to my character. Here you can see what I see when I want to walk forward: 
When I use a mesh collider my character falls through the floor. This I dont understand either.
Is this to hard or to easy to answer? Is there anybody who can help me?
Answer by phodis1970 · Oct 24, 2018 at 08:25 PM
In the rigid body section in the inspector... go down to CONSTRAINTs...and tick Freezerotation On both X and Z ... give that a try.
Your answer