I made game with the AI third person controller, and it works fine. But if I add a roof over my scene, the AI crouches and moves very slowly. Some times he’s even airborne! the top of the navmesh agent is no where near the roof though. I searched the internet and found nothing. I’m using character from the asset store, but the third person controller is still the default unity one. Any idea how I can fix this?
How low is the roof and have you tried raising it a bit? I didn’t attempt this but just looking at the code on the 3P script it draws a sphere and checks against the capsule collider(halved) height and if it finds a collision it sets crouching to true.
void PreventStandingInLowHeadroom()
{
// prevent standing up in crouch-only zones
if (!m_Crouching)
{
Ray crouchRay = new Ray(m_Rigidbody.position + Vector3.up * m_Capsule.radius * k_Half, Vector3.up);
float crouchRayLength = m_CapsuleHeight - m_Capsule.radius * k_Half;
if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, Physics.AllLayers, QueryTriggerInteraction.Ignore))
{
m_Crouching = true;
}
}
}