Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

2D NavMesh PathFinding......

Discussion in '2D' started by Vinnie711, Nov 8, 2017.

  1. TSabos

    TSabos

    Joined:
    Mar 8, 2015
    Posts:
    90
    I have a weird issue trying to define walk paths for NPCs so I set the default action to Non-Walkable and then defined the walk paths shown below. When I start my game there are spawn points and they get spawned in at the start of the arrows but then for some reason teleport to the end.

    Any ideas why this might be happening? I'm not sure if a non closed loop pathing has been tested or not and this would be considered a pretty odd shape I'm sure.

    Edit: So I've placed some nav points in the areas that get teleported away from and they seem to path fine after instantiation. There's just something definitely going on with how the agent finds the closest nav point to attach to when instantiating in. I tried instantiating agents all over the top right horizontal path and they all instantly flashed on the path but then teleported elsewhere.

    Ok this seems to be a Unity specific problem apologies. I set the agent updatePosition to false in awake and then waited some frames before setting updatePosition back to true and it teleports correctly to a nearby path position if it is off the path and works correctly. It also fixed spawning agents correctly on a path and not teleporting randomly.

    Feel like I also had to use agent.Warp(transform.position) after Instantiation and before SetDestination was used..


    Photoshop_Fne2vC5kVy.png
     
    Last edited: Mar 26, 2019
  2. TSabos

    TSabos

    Joined:
    Mar 8, 2015
    Posts:
    90
    What are the performance implications of using this system for runtime spawned trees for a Rust style game that use NavMeshObstacle (talking 200-300 items)? I think that's an important note that this system "can" be used for 2D Colliders if they are not baked into the navmesh if you use obstacles and the Carving feature, but they have to be defined as capsule or box.
     
  3. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    61
    Hi,

    I'm not a game dev, and not Unity expert, and didn't made benchmarks, and navmesh is unity core feature. I made proof of concept, and still it is not a production code, and unity does not treat navmeshcomponents as production))) So it is up to you to find out and leave a feedback.

    But 200-300 navmesh obstacles with carving of static objects is not a problem. As I believe.

    All I can tell that 10k tiles is in milliseconds deal. And I'm glad to hear your findings.
     
  4. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    61
    TSabos likes this.
  5. AmbroseFurback

    AmbroseFurback

    Joined:
    Feb 20, 2013
    Posts:
    10
    This asset works great, thanks!

    I'm trying to learn how to move my agents. I got one that pretty much works great at seeking out a target by doing an agent.destination call. I'm trying to make one that just moves in a set direction until it hits a boundary but I'm not doing well. Can anyone point me at an example or docs that might help? Thanks.
     
  6. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    61
    Hi,

    If you are looking for collision event, I think its very straight forward to use composite collider on tilemap and other collider on agent.

    And if you just want to stay in programmed polygonal boundaries, just create a polygon collider and cast it against collider on agent.
     
  7. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    61
    Hi All,

    Just to confirm, it works with 2019.1
     
    TSabos likes this.
  8. SuperFranTV

    SuperFranTV

    Joined:
    Oct 18, 2015
    Posts:
    8
    Please can you create a Layer-Based System like the Layer of the Tilemap Brush.
     
  9. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    61
    @SuperFranTV Hi,

    Give me more details. You want have multiple navmeshes? Or to bake only the certain layer of tilemap?
    Describe what you want to achieve and I will create the ticket.
     
  10. SuperFranTV

    SuperFranTV

    Joined:
    Oct 18, 2015
    Posts:
    8
    Hello sry for late answer, i want to bake multiple tilemaps with different z positions at the Tilemap-Component is a Variable named tile anchor -> there is a Z positon (layer based like Ground + Tree).

    Next is i need to restart unity if i create Tilemaps (two different) with much tiles, than after restart unity generates the navmesh correctly.
     
    vhman likes this.
  11. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    61
    Hi,

    Recently burned my CPU. But now I'm back)
    Made commit Add height override for Isometric Z as Y Tilemap, so even if tilemaps has Z value, you can set in Override Vector (1,1,0), and all will be flush.
     
  12. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    61
    Back to you @SuperFranTV,

    I'm not experienced Unity dev, so I'm in struggle to understand use cases.
    Can you share print screen or sample scene with case that is not working for you?
     
  13. Mc_Xlebyshek

    Mc_Xlebyshek

    Joined:
    May 6, 2019
    Posts:
    1
    Maybe you can use some elements of this project to update your script?
    * click *
     
  14. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    61
    @Mc_Xlebyshek,

    Hi,

    The project has 1000+ of man-hours or more. And I have only 10h in a month)
    So navmesh plus is about mesh generation of _native_ navmesh for unity, not about AI or agents.
    While Aron Granberg does not use unity pathfinding at all. So its incompatible)

    pro version has mesh generator, nothing to add.
    The single feature I see is to export unity navmesh data to A* mavmesh. But there is nothing to do with NavmeshPlus.

    I can give you guideline how to do it if you want.