Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question NavMesh - Moving only in Z (foward)

Discussion in 'Navigation' started by julio_kolbapps, Dec 22, 2021.

  1. julio_kolbapps

    julio_kolbapps

    Joined:
    Mar 2, 2021
    Posts:
    32
    Hi guys, im working at a 2.5D Platformer game, so my agent need to move only in Z axys. Foward and backward. He need to jump to others plataformers.

    So to start, i need to constraint the movment only in Z.. How to do it? Do anyone could helpme?
     
  2. julio_kolbapps

    julio_kolbapps

    Joined:
    Mar 2, 2021
    Posts:
    32
    I keep looking for answers but I can't find anything.
     
  3. steven1022

    steven1022

    Joined:
    Sep 8, 2012
    Posts:
    21
    Just handle the movement yourself and only move on the axis you care about. Give it a value on Z and it should only move in that direction.

    https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent.Move.html

    To jump, deactivate the Navmesh Agent, make your jump logic based on any tutorial online, and then when the Navmesh lands, reattach and reactive the agent to the Navmesh.

    Here is a example:


    This same guy has a series on NavMesh AI if you want to build your understanding on how to use the system.
    https://www.youtube.com/c/LlamAcademy/videos
     
  4. julio_kolbapps

    julio_kolbapps

    Joined:
    Mar 2, 2021
    Posts:
    32
    Ty for that. I Will Look.