Hello,
i just downloaded a simple Character (Ip_guy) and set up some animation for it. I used this tutorial to do this: Character animation setup tutorial - Live Training Nov. 11, 2015 - YouTube.
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.