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,024
    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:
    3
    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,024
    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:
    3
    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,068
    @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:
    152
    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,716
  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,716
    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.