Search Unity

Navigation2D Official Thread - Use Unity's built in Pathfinding for 2D Games

Discussion in 'Assets and Asset Store' started by mischa2k, Jan 4, 2017.

  1. OJ2KOfficial

    OJ2KOfficial

    Joined:
    Jan 4, 2019
    Posts:
    2
    Yea at its lowest setting "1" it overlaps my boundary sprites and any higher it just gets worse

    these pictures were taken at the setting 1

    Edit: I found out the reason it was acting up was because the parent object of the sprites scale was modified
     

    Attached Files:

    Last edited: Jan 5, 2019
    mischa2k likes this.
  2. bufuu

    bufuu

    Joined:
    Jan 16, 2019
    Posts:
    7
    Hi,
    this asset looks awesome :)
    before i purchase it i have a question. Can u get any information from the agent. For example if the agent finds a way to the destination point or not? how long is the way to the destination ?

    i want to make a tower defense game in 2d and need some information from the monster, so the tower can decide which monster to attack. also i dont want a given path for the monster. the user should be able to built with towers a path for the monsters. i need to check if the user wants to built at a location which would block the monster from reaching the destination.

    cheers
     
  3. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Yes, you can get all the information that you can also get with Unity's built in NavMeshAgent.
     
  4. leisim

    leisim

    Joined:
    Dec 13, 2016
    Posts:
    5
    Hi,
    Does this asset support the CompositeCollider2D?
    Thanks :)
     
  5. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    No, sorry
     
  6. Devastadus

    Devastadus

    Joined:
    Jan 27, 2015
    Posts:
    80
    I'm considering buying this does this support rotation of sprites so they face towards the direction they are moving? like the 3D version? I see from the demo's it shows no rotation.
     
  7. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    You could modify NavMeshAgent2D to also copy the rotation from the built in 3D navmesh agent, yes.
     
  8. AncientEntity

    AncientEntity

    Joined:
    Dec 11, 2016
    Posts:
    11
    Does Navigation2D work with Unity 2018.1? I assume there won't be many problems because most addons from 2017 to 2018 are fine but just making sure.
     
  9. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Yes it works
     
  10. gamerko

    gamerko

    Joined:
    Sep 26, 2018
    Posts:
    8
    @vis2k

    Hi.
    I'm trying to implement a game with Nav2D.

    Can I use the Nav2D algorithm on my server (.net)?

    The client and server are trying to process the same way.

    thank you.
     
  11. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Not sure what you mean, but you definitely need Unity for it to work
     
  12. gamerko

    gamerko

    Joined:
    Sep 26, 2018
    Posts:
    8


    Thank you for your reply.
    We apologize for any inaccurate questions.
    The point of the question is as follows.

    1. Can I extract the path information generated by Nav2D?

    2. Can the Nav2D path algorithm be used in other C # applications?

    Thank you.
     
  13. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    1. Yes, path is available like in the built in NavMeshAgent.
    2. Navigation2D doesn't include a pathing algorithm. It simply uses Unity's built in navigation system and projects it to 2D.
     
  14. supericon

    supericon

    Joined:
    Feb 15, 2013
    Posts:
    63
    Hi - just purchased the asset but it isn't working for me at all. My level is created in Tiled and exported into Unity via Tiled2Unity. When I build the 2D navmesh, I get the below:

    Nav2D.png
     
  15. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Never tried Tiled2Unity myself. Looks like a really complex polygon collider though. I recommend using simple box colliders etc. instead
     
  16. supericon

    supericon

    Joined:
    Feb 15, 2013
    Posts:
    63
    OK - it appears that, even though Polygon collider 2D is said to be supported, it is only supported in a limited way - as such the asset is unsuitable for our requirements. As per 4.6.2 of the Asset Store Provider agreement, I would like to request a refund. Could you confirm an email address I can send the invoice details to?
     
  17. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Just send me your order number here via direct message.
     
  18. juanitogan

    juanitogan

    Joined:
    Aug 18, 2017
    Posts:
    27
    CapsuleCollider2D ?
     
  19. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    ?
     
  20. juanitogan

    juanitogan

    Joined:
    Aug 18, 2017
    Posts:
    27
    I don't see CapsuleCollider2D listed as a supported object. Do you support it? It was added a couple years ago in Unity 5.6, I believe.
     
  21. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Not supported at the moment, sorry.
     
  22. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    V1.28
    • NavMeshAgent2D properties are now truly proxies to the original agent. Serialized values that are shown in the Inspector are only applied in Awake once.
    • NavMeshAgent2D.LateUpdate copies position again just to be sure
    • NavMeshObstacle2D: obst renamed to obstacle for consistency
    • NavMeshAgent2D: default obstacle avoidance set to None because it doesn't work very well.
    • Upgraded to Unity 2017.4.17f1
    • Fix NavMeshObstacle2D.OnDrawGizmosSelected: use .rotation instead of .localRotation to fix gizmo rotation if parent object is rotated
    • Fix NavMeshAgent2D.OnDrawGizmosSelected: use .rotation instead of .localRotation to fix gizmo rotation if parent object is rotated
     
    gferrari likes this.
  23. MrJBRPG

    MrJBRPG

    Joined:
    Nov 22, 2015
    Posts:
    40
    I got a question in regards to usage of Navigation2D with more custom movement behavior:

    Can the Navigation2D handle custom agents with less than expected movements, such as acceleration driven and gravity controlled agents such as bouncing and jumping units?

    I am thinking about maybe using that for developing a game involving fast-moving players and opponents.
     
  24. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    It can do whatever the built in system can do.
    So yes acceleration, but no jumping.
     
  25. paatz04

    paatz04

    Joined:
    Aug 1, 2013
    Posts:
    38
    Do you know why in some scenes I'm getting PathInvalid or PathComplete when clicking anywhere outside of the current walkable navmesh - while in other scenes ( like in your web demo) it returns PathPartial - and the agent walks towards the edge and stop there - this is the behaviour I'd like to achieve but I can't seem to figure out the difference between scenes that work and those that don't work. Would appreciate any hint. Thanks
     
    Dinamytes likes this.
  26. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Try to increase the NavMesh Extends:
    upload_2019-7-16_9-46-22.png
     
  27. paatz04

    paatz04

    Joined:
    Aug 1, 2013
    Posts:
    38
    Thanks for the quick reply!
    Unfortunately no luck - I was actually trying to do the opposite before as well.
    The first image attached works wherever I go outside of the "within" area - the second image doesn't work anywhere - agent would just stop instantly as soon as it should be a PartialPath.
    Screen Shot 2019-07-16 at 7.48.07 PM.png Screen Shot 2019-07-16 at 7.49.06 PM.png
     
  28. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Just to be clear, you want it to be able to move there or not?
     
  29. paatz04

    paatz04

    Joined:
    Aug 1, 2013
    Posts:
    38
    I want the agent to move to the edge when setting the destination outside of the walkable area - so pretty much I want to get a PathPartial, and not a PathInvalid or PathIncomplete.
     
  30. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Are you sure that the way you try to do it works in 3D with the built in navmesh?
    I recommend trying Unity's built in navmesh in 3D, then see if you get the correct way to do it, then do it exactly the same way in 2D.
    2D only uses Unity's built in system, the results should be the same unless I have a bug in there somewhere.
     
  31. paatz04

    paatz04

    Joined:
    Aug 1, 2013
    Posts:
    38
    Well it works in your web-demo - and it works in some of my scenes. That's what PathPartial is for.
    I just can't understand what the difference is between the working ones and the not working scenes.
    Thanks anyway
     
  32. paatz04

    paatz04

    Joined:
    Aug 1, 2013
    Posts:
    38
    Is there maybe a way to mark everything outside of a closed edge collider a non walkable (obstacle) ?

    I noticed creating static box colliders always works. It is still weird because I still have scenes where it also works when it's a walkable area that doesn't have a path.
     
  33. Thenumberfly

    Thenumberfly

    Joined:
    Mar 20, 2017
    Posts:
    5
    Hi there, I am using TileMap Collider 2D in my game but the NavMesh does not seem to generate correctly at all. I am currently on Unity 2019.2 if that helps. Is there something I am missing, or is this a bug? I have tried various agent sizes in the settings but they all make no sense.


    Colliders.PNG
    NavMesh2D.PNG
     
  34. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Did you press the rebake button? It does seem to detect some kind of collider there, otherwise there wouldn't be those holes. Very strange.
     
  35. Thenumberfly

    Thenumberfly

    Joined:
    Mar 20, 2017
    Posts:
    5
    I've tried re-baking it but it always generates the same mesh. The demo scene works fine but it only uses box colliders. I've tried a few different patterns and scales but it always seems to mostly ignore the collider. I looked into the code a bit but I couldn't quite make sense of how it is generating the shapes.

    Do you want me to send you a demo scene? Or would you consider a refund at this point?
     
  36. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    You can get a refund if you send me your order number.
    You can also try to make a video so maybe I see what happens.
     
  37. tonikaku

    tonikaku

    Joined:
    Aug 12, 2019
    Posts:
    2
    Hello. I just purchased it and started using it, but I really want to change the offset value of the collider used for “obstacle avoidance”. But since I am a C # beginner, I don't know which part of which class should be modified. Can't somebody tell me?
     
  38. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    What do you mean with offset value? What are you trying to do exactly?
     
  39. tonikaku

    tonikaku

    Joined:
    Aug 12, 2019
    Posts:
    2
    I want to set the basis of the trigger for changing the "Order in Layer" of SpriteRender for each object. I want to place the center of the "obstacle avoidance" circle below the agent, not the center. (For example, in Unity's standard circle collider 2D, it could be changed by the x and y values of the “offset” in the inspector.) As an alternative method. I attached an agent to an empty object and changed the position of the transform to a child object of the object I want to move. In this case, when playing, only the child object moved, leaving the Root object in place. ( I will attach the image I want just in case.)
    190917.PNG
     
  40. gabriel3491pm

    gabriel3491pm

    Joined:
    Oct 6, 2019
    Posts:
    1
    Hello Vis2k! It would be very interesting to put A* Pathfinding (move in grid) as an option within the project. It's just a question, because it was something I missed when understanding Navigation2D.
     
  41. vmikhaylov82

    vmikhaylov82

    Joined:
    Jun 18, 2019
    Posts:
    6
    Hello. My navigation has stopped working. error: trying reversed polygon. I change the agent radius and click bake, but nothing changes. what to do?
     
  42. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Did you try going back through your backups to see when it started?
     
  43. vmikhaylov82

    vmikhaylov82

    Joined:
    Jun 18, 2019
    Posts:
    6
    Hello. I have an obstacle initially turned off. When the enemy reaches the door, the obstacle turns on, then the enemy again goes where he was going through the door, and he must already find a workaround, he cannot leave the area near the door. Error: stopped agent because of collision in 2D plane. Why is that?
     
  44. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Can you make a video? I don't exactly understand what you mean
     
  45. vmikhaylov82

    vmikhaylov82

    Joined:
    Jun 18, 2019
    Posts:
    6
  46. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Looks like you are making a sidescroller. Navigation2D only works for top down games, sorry :/
    Let me know if you want a refund!
     
  47. vmikhaylov82

    vmikhaylov82

    Joined:
    Jun 18, 2019
    Posts:
    6
    Your navmesh is suitable too. Following a workaround as far as I know does not work in the native navmesh, obstacles in the way only make a shift towards avoiding the obstacles, but if the obstacles block the whole way, then there is no workaround. Therefore, this functionality must be replaced with your own solutions.
     
  48. NickBalanda

    NickBalanda

    Joined:
    Apr 30, 2015
    Posts:
    6
    Hi!

    Is it possible to spawn an agent at runtime?
    I keep getting a lot of "stopped agent because of collision in 2D plane"

    Cheers!
     
  49. Myradorn

    Myradorn

    Joined:
    Nov 25, 2017
    Posts:
    3
    Hello Vis2k,
    using your Navmesh2D for a little RPG Sim Game. It works fine for me until today while running on an isStuck error. Working for about a month now in many different ways, but atm i try to move a character to a fix destination, Done this a hundred times without problems but in my actual Situation, the
    float dist = Vector2.Distance(transform.position, NavMeshUtils2D.ProjectTo2D(agent.transform.position));
    in the isStuck Routine of the NavMeshAgent2D calculates a 2.1*10E-07, where it should be 0 so that IsStuck is not false. Do you know if this is a bug in the distance calculation of Vector2 ?
    It always leads to the "stopped agent because of collision in 2D Plane" Message
     
  50. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Yes it's possible, I do that in uMMORPG 2D too.
    Try to set obstacle avoidance to none, see what happens.
    Try to spawn one in one of the scenes that come with Nav2D.

    Why should it be 0?
    Do you have the latest version?
    Try adding a debug.log to see what 'maxdist' is when it happens.
    You can also try to pause the game, go to scene view in 3D and see what happens in 3D there. the agent and colliders of the real 3d simulation are all in the scene.