Question by
GenericBox · Jul 29, 2018 at 08:13 PM ·
animationmovementcharactercontroller
Character Animation Shake (MakeHuman + Unity MoCap Animations)
I have imported a model from MakeHuman and I am using the free Unity MoCap package for animations. The animations all work great and the rigging appears to be matched well. However, when I move forward/backward -- the longer I hold the "Vertical" Key (my "forward/backward") -- the more ... jittery ... the animation becomes. There is no effect in small movements but it gets worse over time. Video, and CharacterController, attached.
My CharacterController is using Animation parameters to set animation state.
I'm a beginner, so any help would be appreciated, thanks!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
private Animator _animator;
private bool _moving;
private bool _running;
private bool _turning;
private int _direction;
public float WalkSpeed = 3.0f;
public float RunSpeed = 6.0f;
public float RotateSpeed = 150.0f;
// Use this for initialization
void Start () {
_animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
float movementSpeed = WalkSpeed;
_moving = Input.GetAxis("Vertical") != 0;
_running = Input.GetKey(KeyCode.LeftShift) && _direction == 1;
_turning = Input.GetAxis("Horizontal") != 0;
if (Input.GetAxis("Vertical") > 0) _direction = 1;
if (Input.GetAxis("Vertical") < 0) _direction = 2;
if(_running) movementSpeed = RunSpeed;
float x = Input.GetAxis("Horizontal") * RotateSpeed;
float z = Input.GetAxis("Vertical") * movementSpeed;
transform.Rotate(0, x, 0);
transform.Translate(0, 0, z);
_animator.SetBool("moving", _moving);
_animator.SetBool("turning", _turning);
_animator.SetBool("running", _running);
_animator.SetInteger("direction", _direction);
}
}
Comment