Search Unity

Jumping using NavMeshLinks without using an animation

Discussion in 'Navigation' started by SpiccyMayonnaise, Jun 15, 2020.

  1. SpiccyMayonnaise

    SpiccyMayonnaise

    Joined:
    May 10, 2018
    Posts:
    22
    In my project, whenever my agent enters a NavMeshLink that is marked with the "Jump" area, I would like them to jump. Seems simple enough, right?

    All the online sources I could find say that upon entering the NavMeshLink, some sort of animation should play that smoothly moves the agent from the starting position of the link to the end position.

    I would like to know if there is another way to move the agent to the end position.

    Currently I am using a character controller to move my agent, which works fine, but when the agent enters a NavMeshLink, they just keep walking in place. I think that this is because it doesn't "complete" the link, since I have turned off agent.autoTraverseOffMeshLink and I don't call agent.CompleteOffMeshLink()

    Code (CSharp):
    1.         if (agent.isOnOffMeshLink) {
    2.             var link = (UnityEngine.AI.NavMeshLink)agent.navMeshOwner;
    3.  
    4.             if (link.area == 2) {
    5.                 //2 is index of jump layer
    6.                 //Jump just applies an upward force to the CharacterController velocity
    7.                 Jump(true);
    8.             }
    9.         }
    Is what I am trying to do possible, or should I bite the bullet and use an animation?