Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity - problem with my platform and "NavMesh"

Discussion in 'Getting Started' started by Bleteuse, Dec 18, 2018.

  1. Bleteuse

    Bleteuse

    Joined:
    Dec 18, 2018
    Posts:
    4
    Hello,
    My platform moves thanks to the "ontrigger" function, but since the tank can only move on the navmesh calculated at the beginning.
    Do you have a solution? I think we need to generate a navmesh every second again but I'm not sure.
    navmesh.PNG
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    Welcome!

    I've never actually used the NavMesh for anything, but based on my understanding of how it works, I think you're supposed to do it like this:
    • Create planes that will have their visibility turned off at the start and stop locations for the moving platform. Make sure the NavMesh bakes those planes.
    • Add a trigger area for both those planes so that when an agent enters that space, the agent has it's nav functionality switched off.
    • Move the platform. When the platform reaches its destination, re-enable the navmesh agent and have it navigate its way off the platform.
    What I don't know is how the agent will know to try to get to the locations separated from the main navmesh. That might have to be some additional logic you code into their controllers.
     
  3. Schneider21 likes this.
  4. Bleteuse

    Bleteuse

    Joined:
    Dec 18, 2018
    Posts:
    4
    @LurkingNinjaDev but if i use Navmesh obstalce, my tank can not go on the plateform ? and the navmeshlink is for "teleporation" ?
     
  5. Maybe I misunderstood your situation. So your tank will be able to wander around everywhere on this image above where navmesh is present, correct?
    So it can wander downstairs, where the tower on the left is moving. When it is moving it's an obstacle, since it's dynamically changing position on the navmesh.
    When your tank is upstairs and the tower is close to the ramp, you want your tank to get onto the tower, right? So you activate your navmeshlink when the tower is next to the ramp.

    Or really I'm misunderstanding the question. :)
     
    Last edited by a moderator: Dec 18, 2018
  6. Bleteuse

    Bleteuse

    Joined:
    Dec 18, 2018
    Posts:
    4
    @Schneider21 Thanks for the answer but it seems complicated to me. It took me 2 hours to play a music with the function ontrigger:').
     
  7. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    Keep at it! I think the direction @LurkingNinjaDev is pointing you is correct, though. This stuff ain't easy, but anybody can figure it out if they stick to it.
     
    Lurking-Ninja likes this.
  8. Bleteuse

    Bleteuse

    Joined:
    Dec 18, 2018
    Posts:
    4
    @LurkingNinjaDev i would like when my tank, go on the plateforme, this plateforme move to the next cube, without teleportation. navmesh2.PNG
     
  9. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    The simplest way to move things is to use MoveTowards inside the Update loop. You could also use Lerp, or set up a coroutine.
     
    Lurking-Ninja likes this.