So I never got to really mess with animations till now (My first time doing this stuff)
I wanted some basic stuff like idle, running, walking and aiming. I couldn’t really find a good aim animation anywhere (I’m no animator) - The only thing I liked was the character from the Locomotion system.
From there, the animations were all imported as separate .fbx files - they were all Legacy so I turned them into Humanoid. I dragged the animations I wanted and so here is my state machine:
The animations are transitioning correctly, here’s what’s controlling them:
using UnityEngine;
public class MecanimTestController : MonoBehaviour
{
public float rotationSpeed = 1f;
void Update()
{
var animator = GetComponent<Animator>();
if (animator)
{
animator.SetFloat("Speed", Input.GetAxis("Vertical"));
animator.SetBool("IsAiming", Input.GetMouseButton(1));
animator.SetBool("IsRunning", Input.GetKey(KeyCode.LeftShift));
}
transform.Rotate(0, Input.GetAxis("Horizontal") * Time.deltaTime * rotationSpeed * 100f, 0);
}
}
The problem I’m having though is that the character doesn’t move even though “Apply root motion” is ticked. He doesn’t even more when I preview the animation! (at the bottom right corner of the animation) - Also, the guns are always out of place. Here’s a small video highlighting the problems, showing my avatar settings, import settings, etc. - Please give it a view.
Question is: Why isn’t root motion being applied? (why isn’t the character moving) and why is the gun being offset-ted?
Thanks for any help!