Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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,052
    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:
    3
    @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:
    5
    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,052
    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:
    5
    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,166
    @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:
    165
    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:
    50
    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:
    21
    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. jamiewhitephd

    jamiewhitephd

    Joined:
    Jun 8, 2012
    Posts:
    121
    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:
    3
    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.
     
unityunity