The animations are playing fine, however I can't manage to move my character. My script:
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
public float turnSmoothing = 20f;
public float speedDampTime = 0.1f;
public float jumpHeight = 8.0f;
private Animator anim;
private Rigidbody rb;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
}
void FixedUpdate()
{
float h =- Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
MovementManagement(h,v);
}
void MovementManagement (float horizontal, float vertical)
{
if (horizontal != 0.0f || vertical != 0.0f)
{
anim.SetBool("Move", true);
anim.SetFloat("Speed", 6.0f, speedDampTime, Time.deltaTime);
Rotating(horizontal, vertical);
}
else
{
anim.SetFloat("Speed", 0.0f);
anim.SetBool("Move", false);
}
}
void Rotating (float horizontal, float vertical)
{
Vector3 targetDirection = new Vector3(horizontal, 0.0f, 0,0f); //2.5D I just want to move on the x-axis atm
Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
Quaternion newRotation = Quaternion.Lerp(rb.rotation, targetRotation, turnSmoothing * Time.deltaTime);
rb.MoveRotation(newRotation);
}
}
My character's inspector: