If you add script to your character it will disable the root motion when you are off the ground, and enable it if you are on the ground.
private Vector3 m_GroundNormal;
private bool m_IsGrounded;
private Animator m_Animator;
// Use this for initialization
void Start ()
{
m_Animator = GetComponent();
}
// Update is called once per frame
void Update ()
{
CheckGroundStatus();
}
void CheckGroundStatus()
{
RaycastHit hitInfo;
// 0.1f is a small offset to start the ray from inside the character
// it is also good to note that the transform position in the sample assets is at the base of the character
if (Physics.Raycast(transform.position + (Vector3.up * 0.1f), Vector3.down, out hitInfo, .1F))
{
m_GroundNormal = hitInfo.normal;
m_IsGrounded = true;
m_Animator.applyRootMotion = true;
}
else
{
m_IsGrounded = false;
m_GroundNormal = Vector3.up;
m_Animator.applyRootMotion = false;
}
}
Trending Articles
More Pages to Explore .....