Search Unity

Poly|Nav: Pathfinding for Unity2D

Discussion in 'Assets and Asset Store' started by nuverian, Jan 27, 2014.

  1. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    I am sorry for the late replies everyone.
    Please consider joining the discord server for faster support https://discord.gg/97q2Rjh :)
    Thanks!

    From the video it seems that the main PolyNav2D polygon is inverted. Have you tried inverting the main polygon specifically (in the inspector of the @PolyNav2D gameobject) ?
    If possible, please do send me your project to test it out and help you more effectively to (support_AT_paradoxnotion.com). That would be great.

    Thanks!

    Hello,
    I have downloaded and will check out the scene tomorrow first thing. Please remove the attachement though since it is not legal to distribute the software freely/public.
    Thank you.
     
  2. sk1zZ

    sk1zZ

    Joined:
    Mar 30, 2015
    Posts:
    9
    @nuverian Hi! Could you help me with my problem?
    My enemy's agent always stuck in each other when they chase the player. I update an agent's target each frame. How can I fix that? I have these settings for enemies agent:
    upload_2019-5-1_16-52-15.png
    Also in the documentation, I did not find information about "Avoidance Consider Stucked Time" and "Avoidance Consider Reached Distance".
     
  3. kylewill713

    kylewill713

    Joined:
    Jun 22, 2016
    Posts:
    5
    Sorry about that!, deleted the attatchment
     
    nuverian likes this.
  4. m4rtin-t

    m4rtin-t

    Joined:
    Jan 30, 2016
    Posts:
    8
    Is it possible for this nav finder to path find backwards? imagine a car backing up into a parking spot?
     
  5. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,

    PolyNav can find a path from point A to point B. When calling SetDestination to the included PolyNavAgent implementation script, the pathfinder will find a path from the current agent position (point A) and to the target position (point B), and finally traverse the found path if any. There is nothing stopping you however from manually requesting a path from any point A to any point B and then utilize the found path in any way you like in code. The only difference from forwards to backwards as far as I can tell, would be where the agent is facing at. The included agent script will turn to face the direction of the next path point if rotation is enabled (thus forwards), but changing this or adding an extra option to face away from the next point in the path (thus backwards), would be very easy.

    Thank you.
     
  6. m4rtin-t

    m4rtin-t

    Joined:
    Jan 30, 2016
    Posts:
    8
    Thank you very much for the reply, i have another question.
    Is there any built in way to get to your destination with a specific orientation? e.g. once you reach your destination, you must be facing Vector2(0,1)
    Something along those lines.
     
  7. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    @m4rtin-t I think that's not possible out of the box, but afaik there is a way to register to an event when the destination is reached. In the callback you could set the rotation yourself.
     
  8. bnd10706_unity

    bnd10706_unity

    Joined:
    Aug 8, 2019
    Posts:
    4
    I am having a hard time figuring out how to reference the movingDirection from my enemy controller.

    I want to have my NPC wander, and right now He is doing that but with a static image.

    I need to reference his moving direction so I can tell the animator what direction he is moving. I cannot seem to figure it out.
     
  9. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    you can store a vector and compare the current frame position to the previous frame position. if the x is negative then character is moving left, if positive then right, if zero then they standing still.
     
  10. bnd10706_unity

    bnd10706_unity

    Joined:
    Aug 8, 2019
    Posts:
    4
    I guess this is beyond my scope of knowledge. i am just starting out in using Unity.
     
  11. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
  12. bnd10706_unity

    bnd10706_unity

    Joined:
    Aug 8, 2019
    Posts:
    4
    Thank you very much @CarterG81

    Looks like a lot of the code is old, I will have to research how to use it now, it gives me all sorts of errors.

    I understand the theory. But Poly | Nav is moving the character for me, would it not be easier to reference the movingDirection in the NavAgent?

    Again, I am fairly new to all this, so I may be WAY off basis.

    I am building a top down 2D RPG, and just want to animate my NPCs as they Wander around, with a player its easy because you can reference the input on the horizontal or vertical, but with NPCs that have an AI and using Poly | Nav as a tool, its a bit more complicated to figure out what the change in x and y are.
     
  13. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    Oh sorry, I dont have any experience with polynav. Never got a chance to use it. The old/new position logic check would be a fine way to go though.
     
  14. rboerdijk

    rboerdijk

    Joined:
    Aug 4, 2018
    Posts:
    96
    Hello,

    I'm working on a little sidescroller/platform game and noticed the following statement in the assetstore:
    "PolyNav can be great for Adventure, Isometric, Side-Scrollers and Top Down 2D Games!"

    I was wondering there is more info on how it would work, any documentation or maybe a video displaying this functionality? I can envision how it works in a 3D or a 2D top down game, but how would it work in a side-scroller? A different pathfinding solution explicitily mentions that side-scrollers are not supported, so I'm wondering what makes this asset different.

    Thanks in advance!
     
  15. Solidcomer

    Solidcomer

    Joined:
    Sep 12, 2017
    Posts:
    95
    With PolyNav2D, why agents are pushed aways very quickly upon start moving if they sticked together?
    I have installed PolyNav2D plugin, and have several agents, if I click and hold, all agents will move to one place and get overlaped, and when I click another point on the map, all agents will be first pushed away very quickly as if they were added a very strong force.
    With this, I have to attach a rigidbody2D and circleClider2D for each agent, and set Avoid Radius no greater than the radius of the circleClider2D, so that they don't overlap. But I need them to overlap a little bit.
    I'm wondering how to reduce the force that break them apart?
    Attached is the PolyNavAgent params of my agents.
    Thank you very much.
     

    Attached Files:

  16. drjamiearron

    drjamiearron

    Joined:
    Jun 8, 2012
    Posts:
    134
    Can anyone confirm whether this asset is compatible with the latest versions of Unity? I'm hoping someone can confirm it works on 2019.4.0 LTS before I take the plunge and purchase. Many thanks.
     
  17. aasmundwt

    aasmundwt

    Joined:
    Sep 30, 2019
    Posts:
    5
    I currently use PolyNav2D in one of my projects and the NavMaps are pretty big so it takes a while to generate them when you start the application, however they never need to update or change. So I was wondering it's possible to pre-generate the navmaps so it doesn't generate them every time you start the application.
     
  18. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    184
    I am trying to get Opsive Behavior Designer working with PolyNav 2D. I haven't been able to find any documentation to achieve this. @nuverian @opsive Can anyone point me in the right direction? I am happy to take it from there.

    -----------------SOLVED--------------------------

    In case anyone else sees this, it wasn't immediately obvious to me but you have to download an addon from Opsive after entering your invoice number. I have started down the path of this starting to work.
     
    Last edited: Dec 8, 2020
    nuverian and CarterG81 like this.
  19. JuZtchillin

    JuZtchillin

    Joined:
    Nov 6, 2014
    Posts:
    9
    @nuverian Hello I have just purchased PolyNav 2D. I would like to know if this asset supports TIlemap Collider 2D and if so how can I use it? I do not see any setup information about Tilemaps in the documentation. Thanks.
     
  20. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello and thank you for purchasing PolyNav. Unfortunately PolyNav does not TileMapCollider2D right now, even though it is something I want to add support for, naturally. Since I can't promise for when this will be ready and if this is a showstopper for you, please let me know.
     
  21. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    184
    I have what I hope is a simple question. I have a tilemap and have created a composite collider for it. I cannot figure out how to use PolyNav with it. I have tried to add the PolyNavObstacle to my tilemap which contains my composite collider but it doesn't seem to do anything when I select composite as the Shape Type on the PolyNavObstacle. When I select the Composite Shape Type, it seems to disable my tilemap composite colliders completely.

    Should I be approaching this in a different way or can anyone provide some guidance here?

    **edit**

    uh oh. I just noticed the post before this and just realized that composite colliders for a tile map are using Tilemap Collider 2D. Am I completely out of luck here? What are my options now for generating colliders for my tile maps. I really didn't want to have to draw every collider in every scene by hand.
     
    Last edited: Feb 8, 2021
  22. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello and sorry for the late reply. Indeed, Tilemaps are using Tilemap Collider 2D rather than Composite Collider 2D. Unfortunately Tilemap Collider 2D is not supported. It is something I've long wanted to support though, but I can't promise when it will be done :/. If you have any c# code experience, you can implement the support for it in a similar fashion that the other colliders are supported code-wise. In the end, it is a matter of providing the polygons that make up the tiles to PolyNav. Something that can also be done directly through the PolyNav API as well, which is briefly showcases in the CustomMapProvider example script. If you have any questions at all about how to do this, please let me know.

    Thank you!
     
  23. CristianoSalviano

    CristianoSalviano

    Joined:
    Feb 25, 2021
    Posts:
    1
    Hello, I'm using polynav in a 2d project, but in the project I can zoom in / out and pan. I'm having trouble changing the coordinate system, from "position" to "localPosition". The question is: Is there a way to make this change?
     
  24. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello and sorry for the late reply.
    Can you please clarify where exactly you would like to use localPosition instead of position?
    Thank you,
     
  25. TANG-JIA-LANG

    TANG-JIA-LANG

    Joined:
    Jan 18, 2018
    Posts:
    1
    It's great that PolyNav supports TileMap! That's why I use it, but I might have a problem with it. When I use the Click To Move script in the example project To continuously detect the obstacle of ShapeType Composite by long pressing the mouse (continuously changing the target point), the frame will drop seriously (I only have one player). May I ask why this is caused? Could please optimize it? Thank you very much!
     

    Attached Files:

  26. shayneoneill

    shayneoneill

    Joined:
    Nov 6, 2021
    Posts:
    2
    How does it support Tilemap? I cant get it to work with it at all?
     
  27. shayneoneill

    shayneoneill

    Joined:
    Nov 6, 2021
    Posts:
    2
    Ok I worked it out, set it to composite collider, readded the tilemap collider (annoyingly it deletes this) and set the tilemap collider to be part of a composite. Now to figure out how to get the vector, as this thing appears to break the rigidbody I was using before.