AI Agent cannot jump

In that screenshot it looks like you need to add an OffMeshLink if you're using a NavMesh. If the link type is Jump Across then the agent will jump if the jump ability has been added.
 
Can you place a breakpoint within NavMeshMovement.Update and see if it gets to UpdateOffMeshLink?
 
Looking at that screenshot more closely it doesn't look like there is an off mesh link for the character to jump up. I just tried to recreate this and the AI agent was able to jump across and drop down, but it doesn't look like the off mesh link supports jumping up onto a platform.

1573125151439.png
 
Thanks, I have created off mesh link to jump on to platform but still, it fails. See the image below. i put jump ability manual. Can you please try.
1573204508336.png
1573204539608.png
1573204570666.png
 
The jump stop type should be Manual. What does the character do when you get to a ledge?
 
I just tried baking your navmesh but Unity wouldn't bake (no idea why). Can you add the jumping offmesh links to this scene? This is the one that I have been using for testing.
 

Attachments

  • navmesh.unitypackage
    14 KB · Views: 2
I just tried baking your navmesh but Unity wouldn't bake (no idea why). Can you add the jumping offmesh links to this scene? This is the one that I have been using for testing.
please find attachment as you requested.
 

Attachments

  • Test.unitypackage
    15.2 KB · Views: 3
Thank you! I see how you did it now. The NavMeshMovement ability doesn't recognize manual off mesh links but I just added support for it if if it has the Navigation Area set to Jump. If you update NavMeshAgentMovement.UpdateOffMeshLink to the following it'll fix this:

Code:
        protected virtual void UpdateOffMeshLink()
        {
            if (m_NavMeshAgent.currentOffMeshLinkData.linkType == OffMeshLinkType.LinkTypeDropDown || m_NavMeshAgent.currentOffMeshLinkData.linkType == OffMeshLinkType.LinkTypeJumpAcross ||
                (m_NavMeshAgent.currentOffMeshLinkData.linkType == OffMeshLinkType.LinkTypeManual && m_NavMeshAgent.currentOffMeshLinkData.offMeshLink.area ==  NavMesh.GetAreaFromName("Jump"))) {
                // Ignore the y difference when determining a look direction and velocity.
                // This will give XZ distances a greater impact when normalized.
                var direction = m_NavMeshAgent.currentOffMeshLinkData.endPos - m_Transform.position;
                direction.y = 0;
                if (direction.sqrMagnitude > 0.1f || m_CharacterLocomotion.Grounded) {
                    var nextPositionDirection = m_Transform.InverseTransformPoint(m_NavMeshAgent.currentOffMeshLinkData.endPos);
                    nextPositionDirection.y = 0;
                    nextPositionDirection.Normalize();

                    m_InputVector.x = nextPositionDirection.x;
                    m_InputVector.y = nextPositionDirection.z;
                }

                // Jump if the agent hasn't jumped yet.
                if (m_JumpAbility != null && (m_NavMeshAgent.currentOffMeshLinkData.linkType == OffMeshLinkType.LinkTypeJumpAcross ||
                    (m_NavMeshAgent.currentOffMeshLinkData.linkType == OffMeshLinkType.LinkTypeManual && m_NavMeshAgent.currentOffMeshLinkData.offMeshLink.area ==  NavMesh.GetAreaFromName("Jump")))) {
                    if (!m_JumpAbility.IsActive && (m_FallAbility == null || !m_FallAbility.IsActive)) {
                        m_CharacterLocomotion.TryStartAbility(m_JumpAbility);
                    }
                }
            }
        }

I will include a slightly more optimized version in the next update that doesn't have to convert the string every tick. But this should get you going. We are also going to be submitting the next update next week so if you don't want to make the code changes you don't have long to wait.
 
Thank you! I see how you did it now. The NavMeshMovement ability doesn't recognize manual off mesh links but I just added support for it if if it has the Navigation Area set to Jump. If you update NavMeshAgentMovement.UpdateOffMeshLink to the following it'll fix this:

Code:
        protected virtual void UpdateOffMeshLink()
        {
            if (m_NavMeshAgent.currentOffMeshLinkData.linkType == OffMeshLinkType.LinkTypeDropDown || m_NavMeshAgent.currentOffMeshLinkData.linkType == OffMeshLinkType.LinkTypeJumpAcross ||
                (m_NavMeshAgent.currentOffMeshLinkData.linkType == OffMeshLinkType.LinkTypeManual && m_NavMeshAgent.currentOffMeshLinkData.offMeshLink.area ==  NavMesh.GetAreaFromName("Jump"))) {
                // Ignore the y difference when determining a look direction and velocity.
                // This will give XZ distances a greater impact when normalized.
                var direction = m_NavMeshAgent.currentOffMeshLinkData.endPos - m_Transform.position;
                direction.y = 0;
                if (direction.sqrMagnitude > 0.1f || m_CharacterLocomotion.Grounded) {
                    var nextPositionDirection = m_Transform.InverseTransformPoint(m_NavMeshAgent.currentOffMeshLinkData.endPos);
                    nextPositionDirection.y = 0;
                    nextPositionDirection.Normalize();

                    m_InputVector.x = nextPositionDirection.x;
                    m_InputVector.y = nextPositionDirection.z;
                }

                // Jump if the agent hasn't jumped yet.
                if (m_JumpAbility != null && (m_NavMeshAgent.currentOffMeshLinkData.linkType == OffMeshLinkType.LinkTypeJumpAcross ||
                    (m_NavMeshAgent.currentOffMeshLinkData.linkType == OffMeshLinkType.LinkTypeManual && m_NavMeshAgent.currentOffMeshLinkData.offMeshLink.area ==  NavMesh.GetAreaFromName("Jump")))) {
                    if (!m_JumpAbility.IsActive && (m_FallAbility == null || !m_FallAbility.IsActive)) {
                        m_CharacterLocomotion.TryStartAbility(m_JumpAbility);
                    }
                }
            }
        }

I will include a slightly more optimized version in the next update that doesn't have to convert the string every tick. But this should get you going. We are also going to be submitting the next update next week so if you don't want to make the code changes you don't have long to wait.
Thanks, I will wait for the update.
 
Top