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,038
    Sorry for the late replies everyone.

    Hello,

    Please let me address your questions.

    1) I wouldn't recommend having a Rigidbody2D on a PolyNav Agent if it is not required, considering that PolyNav itself does rely or use any Unity physics. You can of course still have a kinematic Rigidbody2D for non-kinematic purposes if you'd like (like for example triggers).

    2) Changing the code to use rigidbody2D.MovePosition, instead of directly setting the transform.position, would be rather easy. All you need to do, is change the property named "position" in PolyNavAgent.cs line #83.
    This is the original code:
    Code (CSharp):
    1.         ///The position of the agent
    2.         public Vector2 position{
    3.             get {return transform.position + (Vector3)centerOffset;}
    4.             set {transform.position = new Vector3(value.x, value.y, transform.position.z) - (Vector3)centerOffset;}
    5.         }
    You can for example change the setter code to something like this:
    Code (CSharp):
    1.             set {rigidBody.MovePosition( new Vector3(value.x, value.y, transform.position.z) - (Vector3)centerOffset );}
    (where "rigidBody", is a new variable you need add to the script:
    Code (CSharp):
    1. public Rigidbody2D rigidBody;
    Please let me know if that works for you.
    Thank you!

    Hello,

    The correct way to use CompositeColliders in PolyNav, would be to use them as obstacles only, while the polygon on the PolyNav2D main gameobject, remains PolygonCollider2D, or BoxCollider2D, encapsulating the boundaries of the navigation map (with composite collider-based PolyNavObstacles inside).

    Thus, just add the PolyNavObstacle script on your CompositeColliders you want to act as obstacles, and set the "Shape Type" in the inspector to "Composite" (should be done automatically).
    CompositeCollider.png

    Once again, the collider on the PolyNav2D object, should remain a PolygonCollider2D or BoxCollider2D, with it's boundaries encapsulating the outer borders of the whole navigation map.

    Let me know if you need any more clarifications.
    Thank you.

    Thank a lot! I am glad you like PolyNav.
    Yes, you can use PolyNav's pathfinding for something like this. A path can be requested without the requirement of setting the destination of an agent, or an agent at all for this matter, but rather directly.
    In the set of included playmaker actions, there is a "CalculatePath" action, which will basically find a path from A to B and fire an event accordingly. This action is very simple and can be a good starting point for an action like the one you want. Here is a quick start action for you:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3. using PolyNav;
    4.  
    5. namespace HutongGames.PlayMaker.Actions{
    6.  
    7.     [ActionCategory("PolyNav")]
    8.     public class GetPathDistance : FsmStateAction {
    9.  
    10.         public FsmVector2 from;
    11.         public FsmVector2 to;
    12.         public FsmFloat store;
    13.  
    14.         public override void Reset(){
    15.             from = null;
    16.             to = null;
    17.         }
    18.  
    19.         public override void OnEnter(){
    20.             if (!PolyNav2D.current){
    21.                 Finish();
    22.                 return;
    23.             }
    24.  
    25.             PolyNav2D.current.FindPath(from.Value, to.Value, PathReady);
    26.         }
    27.  
    28.         void PathReady(Vector2[] path){
    29.             if (path != null){
    30.                 float dist = 0;
    31.                 for (var i = 0; i < path.Length; i++){
    32.                     dist += Vector2.Distance(path[i], path[i == path.Length - 1? i : i + 1]);
    33.                 }
    34.                 store.Value = dist;
    35.             }
    36.             Finish();
    37.         }
    38.     }
    39. }

    Let me know if that works for you.
    Thanks again!

    Unity should let you know :)
    The asset store window in the Unity editor has a notification button (mailbox icon) which informs you of asset updates :)
    Thanks!
     
  2. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,081
    @nuverian Hey there, I just wanted to generaly ask what's next for this plugin. Is there some kind of roadmap?
     
  3. nopogo

    nopogo

    Joined:
    Sep 9, 2012
    Posts:
    15
    Any progress in this area? Is there any way I can be of assistance, maybe send you an example project?
     
  4. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    52

    Hi!
    First of all thanks for the answer, that clarified for me how to work with CompositeColliders on the obstacles. That will come in handy for sure in the future.
    But in my case I need the PolyNav2D main gameobject to be a CompositeCollider, as I want to extend the area the agents can use on the fly. Is there any way to make this possible? Can you please look into this for me? :)
    Otherwise the only way I can see is to use the polygoncollider and recreate it everytime or extend it by hand by adding the new points in code, and this is exactly what I wanted to prevent.

    Thanks for this amazing asset,
    John

    Edit: Implemented this functionality myself, as I couldn't wait anymore. Was rather easy actually. Your code is nice and clean. => Sent the updated code to you via PM. ;)
     
    Last edited: Jun 30, 2018
  5. Ostapich

    Ostapich

    Joined:
    May 18, 2018
    Posts:
    1
    Good afternoon!
    I'm new, but I'm very tired of finding ways. It did everything right, but why does not it look for a way. The enemy must follow the protagonist, he follows, but does not overcome obstacles, at some point he just gets up and the beam from the gizmo disappears. Tell me please, maybe somewhere you need to put a dummy?
     
  6. zenmetzger

    zenmetzger

    Joined:
    Apr 2, 2018
    Posts:
    2
    Greetings, I am curious if there is a way to use polynav in a way that limits paths generated to 45 degree directions to accommodate an 8-directional spritesheet. This implementation of polynav doesn't need to handle more that 3-4 agents at the same time so a performance drop is acceptable, it is mostly to prevent floaty animations with 2d isometric character sprites.
     
  7. Kathar3D

    Kathar3D

    Joined:
    Aug 24, 2014
    Posts:
    8
    Thanks a lot nuverian! Works like a charm! :) Occasionally it returns a value of 0, but I think that might just be where a position/path I'm testing is in a wall or something, and a path might struggle to be calculated anyway. So might just be more of a case of me tweaking my game's logic slightly :) Thanks again!
     
  8. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,038
    Hello and sorry for the late reply.
    Apart from optimizations and bug fixes, there are currently no planned features in the roadmap since I can't really think of any at this point, but you are welcome to let me know if you have some ideas ;)
    Thanks!

    Hello,
    Unfortunately after fiddling around trying to fix this, I wasn't able to make holes work as of yet with the current implementation of PolyNav and will require some heavy code refactoring :/ Due to the -rather unexpected- heavy refactoring required, unfortunately I really can't tell for sure when this will be supported. I am really sorry for the inconvenience :(

    Thanks a lot for sending me your implementation!
    I will definitely add this as part of the next version. :)
    Thanks again!

    Hello,

    When you encounter unexpected behaviour from obstacles (or the map as a whole), the first thing I recommend to check, would the the "invert" option found in the inspector of PolyNavObstacles. The thin grey borders of obstacles should always look to the inside of the map like in this image.
    Borders.png

    Checking the "Invert" option inverts the winding of the polygon (thus the border).

    Let me know if that was indeed the cause of the problems you are encountering.
    Thank you.

    Hello,

    Due to the fact that PolyNav is not grid/tile based, my last attempts to make it work in restricted direction were rather very hacky and not working quite well, thus I wouldn't' really recommend trying to hack PolyNav into a restricted direction movement (unless of course you come up with better hacks that I did :) ).
    A grid/hex based solution I think would be a better fit, since it comes with such a restricted movement for free.

    Thanks.

    You are very welcome!
    I am glad it worked for you :)
     
  9. DanielThomas

    DanielThomas

    Joined:
    Mar 30, 2013
    Posts:
    66
    Hi,
    Something I would be interested in (not sure if it has been requested before) would be "links" similar to Unity's Navmesh "offmeshlinks" https://docs.unity3d.com/Manual/nav-CreateOffMeshLink.html

    Or is there an easy way to do this already? ( I mainly use Playmaker, so can't say I dug in to the code that deep)
    Thanks!
     
  10. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,038
    Hello,
    While there are not such links similar to Unity's navmesh, it is possible for the agent to switch between different PolyNav maps in the scene simply by setting the ".map" property of the PolyNavAgent. There is though no custom PolyNav action for setting that property, but I believe Playmaker has an official action for setting properties in general. If not, I can definitely make a PM action that sets this property for you though.

    With that said, changing the map on the fly is not very similar to off mesh links, but it is still a way to change which navigation map the agent is using :) Is this something that would work for you?

    Thanks!
     
  11. DanielThomas

    DanielThomas

    Joined:
    Mar 30, 2013
    Posts:
    66
    Thanks for the reply.
    I think I'm thinking of another scenario. From what I understand navmesh uses these links to calculate distance, so they can be used as a shortcut.

    For an example in this screenshot:
    https://docs.unity3d.com/uploads/Main/OffMeshLinkSetup.svg

    So if the character is standing next to a link it will understand it will be faster to use that rather than walking all the way around.

    I'm guessing you could go about it and do it with a bit code - making the character check if there is a link closer than the final destination. If there is, check if the link+ link end to final destination is shorter than pathfinding distance - if so go to the link and teleport to link end and then resume pathfinding to the destination. Cost I'm guessing you can just do some math on the distance.

    Alright, so now I know it would probably be fine if I put some effort in to it as described above, so better keep Polynav clean as it is :)
     
    Last edited: Aug 1, 2018
    nuverian likes this.
  12. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,081
    @nuverian Hey there, me again :)

    A while ago I asked for a roadmap and you stated that the package is basically in a complete state and besides minor stuff (bugfixes) there is not that much you're going to add.
    I looked at the topic and some of the reviews and was interested if some of specific requests/features have been implemented:

    1)
    Is this possible in the latest version?

    2)
    Have these two points been adressed?

    3) Do agents still slow down when an obstacle is in front of them? If yes, can I prevent that in an easy way? Can we control the accelerations of agents?

    4) Someone posted this:

    Is something like this possible?

    5) I've seen that there have been some requests for sprite sorting (https://forum.unity.com/threads/poly-nav-pathfinding-for-unity2d.224962/page-9#post-2327668) And most of the time you sent them the code. Wouldn't it be easier just to implement it to PolyNav or is it already?

    6) Another user asked this, which is also relevant for our game:
    Any chance PolyNav offers a solution for this?

    7) A user asked this:
    Is that possible as of now?

    8) Another user asked used if one could define both a walkable area for below and above the bridge in this picture:



    Does PolyNav support this?

    9) Another user had a problem with agents shaking when trying to get to a certain spot:


    [FONT=Roboto, -apple-system, BlinkMacSystemFont, Segoe UI, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, Helvetica, Arial, sans-serif]Was this issue adressed?

    10) There were some reports by users regarding inverted polygons.
    https://forum.unity.com/threads/poly-nav-pathfinding-for-unity2d.224962/page-14#post-3092570
    [/FONT]
    I know that there is apparently an option to Invert Polygons in the PolyNavObstacle-Component, but has there been kind of a "quality of life" update to handle these situations or identifying them better?



    I don't exactly now which features now have been implemented and which not from, since some of them have been requested over a timespan of multiple years.


    On top of these questions I have some more specific questions:

    I want my agents to do specific things, like this: imagine a human character who, based on his "States" should do this:
    - walking to a, picking the box up, bringing the box to a specific destination with all the respective animations also while carrying the box being slower than usual
    - pulling/pushing specific objects or even the player

    In my head this shouldn't be a problem since most of that would be the AI-Code which handles when and how to move or should I look out for something related to PolyNav when trying to do this?


    Thanks in advance for your time addressing my questions :)
     
  13. nuverian

    nuverian

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

    I am sorry for the late reply due to summer vacation!

    Please let me address your questions:

    1) There is no invert in BoxCollider, because a BoxCollider always has it's vertices winded properly, which is not always the case for a PolygonCollider and thus the reason why Invert only works in PolygonCollider. I haven't really found a case where there is need for inverting a BoxCollider :)

    2) Differentiation between agents can be done by having the same navigation map (duplicate) with different "radius" property and setting each agent respectively to "use" a different map. Within the same navigation map though, all agents will work with the same radius.

    3) Yes, agents do slow down when an obstacle is ahead, but that is simply a property (Look Ahead Distance) which can be turned down to zero (off).

    4) Having a NavObstacle as a child of a "moving" gameobject, will result in the navigation map being constantly re-generated due to the NavObstacle also being moved. While this is definitely not something I would recommend doing for performance reasons, it will work, but depending on the rest of the map complexity it might be unusable due to the performance drop taking place for the map re-generation.

    5) The automatic sprite sorting scripts are not included in the PolyNav package because they are very specific to adventure games perspective and style, but as you said, I would gladly send the scripts to anyone that wants them :)

    6) I had given a try to implement something like this in the automatic sorting scripts (5 above), but didn't end up with a clean implementation by then and considering it was slightly unrelated to PolyNav itself being a pathfinding system, I didn't end up completing this. Thus the automatic sorting scripts do not work for such isometric game cases, hence why I stated above that they are very specific to adventure games and the reason not included in the PolyNav package.

    7) Unfortunately no, there is no way yet to do this out-of-the-box.

    8) This can be achieved now by creating two separate navigation maps and swapping the map that the agent is currently using when going up or down the stairs for example.

    9) Shaking such as this can take place due to a numerous reasons, but most prominently by extreme high or low value agent settings, like for example a super low "Mass", or a very high "Look Ahead Distance".
    With that said, there have been some improvement over the course of the updates to minimize that potential.

    10) There has indeed been a "quality of life" update in this regard which I've recently implemented, but haven't yet send to the Asset Store and something I am about to do so soon :)

    11) There should really be any PolyNav only related stuff you would want to look out for your example other than of course making the agent moves, since like you said, these are mostly up to the AI-Code responsible to also invoke PolyNav API for the agent navigation and/or altering the agent settings on the fly if need be :)

    Pheww ..Those were a lot :)
    I hope I've answered your questions.

    Thanks!
     
    BTStone likes this.
  14. jungbyungchan

    jungbyungchan

    Joined:
    Aug 4, 2015
    Posts:
    1
    hi, Me send automatic sprite sorting scripts ? Plz ( My englinsh sorry)
     
  15. peon

    peon

    Joined:
    Aug 6, 2012
    Posts:
    13
    Hi @nuverian,

    Great asset but,

    There's a significant freeze every time I remove or add Nav Obstacle on the fly. I read the whole and thread, but I'm still not quite sure if there is a fix/work around for this. There's a support for multiple maps (?), but no examples or any mention in the docs about how to use them for doors, breakable objects and such.

    In my game I have proc generated levels. I'm using Composite colliders for walls, which works fine (thanks for adding the support!). I also have Nav Obstacles that can be added/removed in run time.

    Is this just impossible with this asset without the freeze? To have stuff like doors that can be locked, opened and closed?
     
    Last edited: Sep 23, 2018
  16. smasters654

    smasters654

    Joined:
    Dec 20, 2013
    Posts:
    37
    Hi @nuverian

    I sent you and email a couple of days ago with screenshots of my profiler view. Please let me know what I can do about it, if there is anything. Thanks.
     
  17. WLewis47

    WLewis47

    Joined:
    Jul 6, 2018
    Posts:
    4
    First, great asset. It is exactly what I'm looking for.

    I have a loading improvement question.

    I've drawn a map of England using Tilemap. It is about 700 x 700 tiles, and 45,000 x 44,000 pixels. There are about 55 PolyNav Obstacles that use the Composite Collider generated from Tilemap Colliders. It loads very very quickly with only a few (<5) PolyNav Obstacles. But when I activate all of the PolyNav obstacles, it takes about 3.5 - 4 minutes to load. If I uncheck Repath, Restrict, and Debug Path on the Agent, and Set AutoRegenerate on the PolyNav2D to 0, it does not change the load time (it shouldn't). FWIW, once a build loads it runs smooth as can be with a low CPU and Memory usage.

    If I load PolyNav Obstacles as the Agent approaches, it causes everything to pause until the new Obstacle is loaded.

    Is there a good way to speed up the load time? Is the complex shape of the Composite Colliders slowing the loading down?

    My goal is to expand this to a 6,000 x 4,700 Tilemap with about 1200 polynav obstacles, so it would be ideal if I could cut that load time down.

    UPDATE: If I use one very large and complex Polygon Collider load time is quick: ~ 10 seconds. My temporary solution is to have this large Polygon Collider as my PolyNav Obstacle, but it would be nicer to use the Composite Colliders from my Tilemap Colliders as PolyNav Obstacles to avoid the repetition.
     
    Last edited: Sep 25, 2018
  18. jasonxtate66

    jasonxtate66

    Joined:
    Nov 21, 2017
    Posts:
    132
    This is a simple problem I've had with the script,

    Let's say my enemy is dead, the death animation plays as it is still slightly following the player.
    I've tried to freeze the position of the rigidbody on the enemy, but it doesn't work.

    What would be your easiest suggestion to make the script stop following the player once their health was at 0?
     
  19. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,038
    Hello and I am very sorry for the late reply, but I've missed your post completely.
    The ability to re-generate the map in runtime, is really not there for dynamically altering the map for cases like doors for example, but rather only as a way so that procedural maps can be generated in-game.

    Regarding the ability to use multiple maps, there is a "map" property in the PolyNavAgent inspector (which is of type PolyNav2D). You can set this property within runtime to any PolyNav2D map you want the agent to use, and it will instantly change to now use that new map set (there will be no performance hit in doing this at all). Thus, you can have multiple maps (most commonly used for different agent sizes) but also alter between one another on the fly.
    Unfortunately dynamic obstacles like doors opening-closing, is not something that is supported performance-wise right now, and until I give it a shot at using a different thread, or even trying out the new c# job system of Unity.

    Please also kindly read my answer bellow I give to WLewis47 about performance considerations.

    Thank you!

    Hello,
    I have replied to your email. Please let me know.
    Thanks.

    Hello and thanks. I am glad you like PolyNav.
    As per your "edit", indeed; using the lowest possible amount of PolyNavObstacles and regardless how complex they are, will always yield a far better performance. Thus, right now the best performance-wise approach as far as map generation goes, is indeed to use the least amount of obstacles possible, even though they can be as complex as required.

    Thank you!

    Hello,

    PolyNav does not need or rely on Unity's rigidbody for moving the agents, thus if you want to stop an agent from moving towards the destination you have set it out to reach, you simply have to call `agent.Stop()` function on that agent.

    Please let me know if that works for you, or if I misunderstood the question.

    Thank you!
     
  20. jasonxtate66

    jasonxtate66

    Joined:
    Nov 21, 2017
    Posts:
    132
    Please explain the agent.Stop() more, would I put it on the followtarget or in the enemy script?
     
    Last edited: Oct 1, 2018
  21. jasonxtate66

    jasonxtate66

    Joined:
    Nov 21, 2017
    Posts:
    132
    If you could give me an example that would be awesome.
     
    Last edited: Oct 1, 2018
  22. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,038
    Hello again,

    `Stop()`, is a function you need to call in your code somehow, to make your enemy stop moving when your player health is zero.
    Here is some example code for you.

    Let's suppose this is your "Player" script. It doesn't do much, but it has a health variable we need to use:
    Code (CSharp):
    1. ///Your Player Class
    2. public class Player : MonoBehaviour{
    3.    
    4.     public int health = 10;
    5.  
    6.     ///some other code
    7. }
    This could be your enemy script. It's a slightly altered version of the example "FollowTarget" script:
    Code (CSharp):
    1. ///Your Enemy Class
    2. public class Enemy : MonoBehaviour{
    3.  
    4.     public Player player;
    5.    
    6.     private PolyNavAgent navAgent;
    7.  
    8.     void Awake(){
    9.         //Cache the PolyNavAgent component
    10.         navAgent = GetComponent<PolyNavAgent>();
    11.     }
    12.  
    13.     void Update() {
    14.         //If player is assigned and it's health is greater than 0
    15.         if (player != null && player.health > 0){
    16.             //Pathfind to player position
    17.             navAgent.SetDestination( player.transform.position );
    18.         } else {
    19.             //Otherwise Stop moving
    20.             navAgent.Stop();
    21.         }
    22.     }
    23. }
    24.  
    I hope this helps :)
     
  23. jasonxtate66

    jasonxtate66

    Joined:
    Nov 21, 2017
    Posts:
    132
    Thank you so much
     
    Last edited: Oct 1, 2018
  24. jasonxtate66

    jasonxtate66

    Joined:
    Nov 21, 2017
    Posts:
    132
    I think I have it. So I could really just insert this into my enemy script? And not use the follow target script? Or alter my existing?
     
  25. jasonxtate66

    jasonxtate66

    Joined:
    Nov 21, 2017
    Posts:
    132
    And what about adversely, if I wanted the enemy to stop when he reached 0 health?
     
  26. lightningGamer

    lightningGamer

    Joined:
    Feb 19, 2013
    Posts:
    49
    Hi Nuverian,
    Hope everything is going well! I bought your asset and It's working pretty well for me. However I'm making a small RTS style game and I've noticed 2 things.
    1. My units have avoidance which works pretty well, but I was wondering if there is an easy way to make them treat other units as obstacles to move around them instead of not pathing through them. If there isn't an easy setting for that don't worry about it.
    2. I'd prefer if my units all just had a fixed movement speed and always went that speed. Is there a way to remove the acceleration and deceleration so they just have a fixed speed?
    Thank you for your help!
     
  27. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,038
    Hello again and sorry for the late reply, but I've missed your posts.
    Can you please clarify your question?
    If you want the enemy to also stop when HE reached zero health, you will of course need to also have a "health" variable in your Enemy class as well as checking that variable in a similar manner. Something like this:
    Code (CSharp):
    1. public class Enemy : MonoBehaviour{
    2.     public Player player;
    3.     public int health = 10;
    4.  
    5.     private PolyNavAgent navAgent;
    6.     void Awake(){
    7.         navAgent = GetComponent<PolyNavAgent>();
    8.     }
    9.     void Update() {
    10.         if (player.health > 0 && this.health > 0){
    11.             navAgent.SetDestination( player.transform.position );
    12.         } else {
    13.             navAgent.Stop();
    14.         }
    15.     }
    16. }

    I hope that helps.

    Hello!
    Thank you. I am glad that PolyNav works for you.
    Please let me address your questions.
    1. Unfortunately there is no such ability to treat other agents as obstacles, other than how currently the avoidance works. :(
    2. If you want a totally constant speed, you can crank up Acceleration and Deceleration to something like 50, set Slowing Distance to 0 and Mass to 1. These will remove all smoothing and the speed will be constant :)

    Let me know if that works for you.
    Thanks!
     
  28. lightningGamer

    lightningGamer

    Joined:
    Feb 19, 2013
    Posts:
    49
    Thanks for the reply Nuverian, Don't worry about #1, i can work around that.
    For 2, I tried your idea:
    2. If you want a totally constant speed, you can crank up Acceleration and Deceleration to something like 50, set Slowing Distance to 0 and Mass to 1. These will remove all smoothing and the speed will be constant :)
    That does work in giving my units constant speed, however it also appears to make them disregard avoidance altogether, and units will therefore just move through each other and or go to the exact same location. Anyway to keep the constant (or close to constant) speed and still have the avoidance work? Thanks again for your time! :)
     
  29. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,038
    Hello again and very sorry for the late reply :(
    One solution would be to please open up PolyNavAgent.cs and change line #462 (in LookAhead method) to this:
    Code (CSharp):
    1. velocity += ((Vector2)steer) * velocity.magnitude * otherAgent.velocity.magnitude;
    This way the velocity of both agents is taken into account and is probably better as well. If you find this change does not work for you, you can alternatively multiply the "steer" added by some custom value (and probably expose that value as a field in the inspector). For the next version, I will keep the change line mentioned above and probably add a multiplier in the inspector as well.

    Let me know if that works for you.
    Thank you and once again sorry for the late reply!
     
  30. indiziertbln

    indiziertbln

    Joined:
    Aug 31, 2018
    Posts:
    1

    Can you please send me the two scripts via PM?

    Excuse me, my English is not the best.
    Thank you very much. Best regards Nino.
     
  31. Garainis

    Garainis

    Joined:
    Oct 14, 2013
    Posts:
    15
    Hi, I see that this asset has official NodeCanvas and Playmaker support. Any plans to also support Ludiq's Bolt? It's currently the most popular visual programming tool. It was a part of Unity Plus subscription awhile back too so it has a nicely sized community.
     
  32. nuverian

    nuverian

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

    Visual scripting assets like Bolt, or our own FlowCanvas, should not really need any special integration with PolyNav or most existing assets, since the API (functions, properties, events) of PolyNav can directly be accessed via reflection by the visual scripting software. This is at least the case with FlowCanvas, but I think it is so with Bolt as well.

    This is using a PolyNav function and event in FlowCanvas for example.
    FC-PolyNav.png
    but it should be very similar in Bolt as well.

    Thanks!
     
  33. jasonxtate66

    jasonxtate66

    Joined:
    Nov 21, 2017
    Posts:
    132
    Have integrated PolyNav into a random dungeon generator with a mini map, etc...
    It was not easy, but the results are pretty cool and it performs well. I think the build in NavMesh from unity may run quicker, but you can't really beat this for the ease of use.
     
  34. Foxeh-3

    Foxeh-3

    Joined:
    Jan 19, 2018
    Posts:
    3
    this asset is pretty awesome! i like how petite and non-cluttered it is :)
     
    Last edited: Jan 3, 2019
  35. Crystan

    Crystan

    Joined:
    Oct 11, 2014
    Posts:
    20
    Edit: As suspected the Author was on holiday, he replied to my mail and answered my question. :)

    Hi, sadly the Author didn't respond to my mail (I assume he's on vacation), so I hope my question might be answered by one of the people here on the forum. :)

    I'm currently working on a JRPG (FF6,Chrono Trigger etc) inspired game with a (2D) overworld like featured in such games and I'm looking for a path finding solution for enemies/party members. The game will have more or less bigger scenes/maps that will (hopefully) work without loading screens for the most part through streaming.

    I do know that the asset supports multiple "path maps" but due to the size of the scenes i have concerns about the performance. I already bought another asset (SAPD2D) that makes use of a grid based system but the performance impact is quite notable when generating "longer paths" (around a small forest for example). Would this asset preform better in such cases or is this a general behavior of A* solutions?

    I also would like to mention that i'm not constantly generating any paths. A path is only generated once when the direct path is cut off, otherwise the object just moves directly to the destination.
     
    Last edited: Jan 15, 2019
    Foxeh-3 likes this.
  36. Foxeh-3

    Foxeh-3

    Joined:
    Jan 19, 2018
    Posts:
    3

    i only just bought this like a couple of days ago and i'm loving it.
    i'm not sure how much of a performance hit it will take, but i believe you can swap out the swap out the polyNAVs it generates to help on performance.. but i haven't tested that (yet) so i don't know if it's better to have a giant polynav map or have multiple chunks to swap between.
    i'm sure someone else may have a better answer than me.
     
  37. Foxeh-3

    Foxeh-3

    Joined:
    Jan 19, 2018
    Posts:
    3
    Ok so i've been using polynav2d for my sidescroller platformer and have a couple of questions to help me decide what i am going to do next. (going to edit this post multiple times to shorten my questions)


    1. let's say if an agent gets stuck and the OnInvalid function is called, is there a way for it to just pick a previous waypoint instead of the closest/random one?

    2. I like how the PolyNavObstacle makes nodes on the corners of colliders. is there a way to make a PolyNavObstacle that does the opposite? ex: some sort of interest point that it sees along the path and goes into it instead of around it? not as a primary goal

    so like a obstacle, but instead of the node is in the center of the polygon so the AI goes through it?

    i'm not sure if i'm explaining myself too well so i made a picture of what i was trying to do.
    something like option 2 or 3 in this crude image. i figured it would be great for being able to collect optional stuff.


    i understand that i could just make 2 polyNavObstacles to direct it to go in the middle, but as i understand it, that would create more nodes than just a single one that goes right to the interest.

    3. about the polynav... is there a way we can turn the waypoint list into a tree instead of a linear goal for like branching paths that meets at an end?
     
    Last edited: Jan 4, 2019
  38. nsfnotthrowingaway

    nsfnotthrowingaway

    Joined:
    Feb 18, 2016
    Posts:
    45
    Hi, I'm having the same problem as @nopogo . It's an important limitation, because any level that isn't a perfect rectangle/square will need to have an enclosed area for the characters to navigate around in. Any chance this will be fixed?
     
    Last edited: Feb 3, 2019
  39. nuverian

    nuverian

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

    I am sorry for the late reply, but I completely missed your post. Thanks for getting PolyNav. Please let me address your questions:

    1) This is not really possible out of the box. If you enable "Closest Point On Invalid" option in the PolyNavAgent inspector though, it will do a similar thing, in which the agent will move the closest "valid" point instead.

    2) Not possible out of the box, but I could make it possible to create custom PolyNavObstacles and thus implement what points are created by overriding an abstract method, if that is something that helps. Let me know :)

    Furthermore, I would also add, that if you want, you can provide the navigation map obstacles completely via coding without the requiredment of PolyNavObstacles or colliders at all. A demonstration of how this can be done, can be found in the "CustomMapProvider" script that comes with PolyNav.

    3) Could be possible if you change the source code, but it would probably be a lot of work since that was never taken into account.

    Thanks.

    Hello,
    I am really sorry, but this has yet to be fixed since I really need to refactor the whole implementation as far as navigation map generation goes for this to work, which is something I do want to get down doing so.
    Thank you.
     
    Foxeh-3 likes this.
  40. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,081
    Hey @nuverian any updates on this plugin? The last update was March last year :)
     
  41. small-U

    small-U

    Joined:
    May 10, 2013
    Posts:
    14
    upload_2019-3-14_19-53-57.png red line
    PolyNavAgent point, bug state
     
  42. small-U

    small-U

    Joined:
    May 10, 2013
    Posts:
    14
     
  43. small-U

    small-U

    Joined:
    May 10, 2013
    Posts:
    14
    hi guys, PolyNavObstacle If the object rotates,
    SetDestination Not working properly, sorry my English
    PolyNavObstacle Scale (-1,1,1)
     
    Last edited: Mar 16, 2019
  44. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,038
    Hey,

    I know I have to fix the Tilemap support, but are there any other particular requests? :)
    Thanks.

    Sorry, it's hard to understand :) Do you mean when the obstacle is roatating dynamically, or when the obstacle is rotate at all? Please clarify a bit more. Thank you.

    @everyone . Please join us on the ParadoxNotion Discord Server (#polynav) for support! :)
     
    Brogan89 likes this.
  45. small-U

    small-U

    Joined:
    May 10, 2013
    Posts:
    14
    polyNavObstacle.transform.localScale = new Vector3(2,-2,2)
    transform.localEulerAngles = new Vector3(0,0,90);
     
  46. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    220
    Hey, great asset! Sorry if this has been asked before, but is there a way to check if a position is a valid location to go to, so I can avoid calling SetDestination if it's invalid?

    It seems now when I click on an invalid point, the agent tries to go there, and sometimes gets stuck trying to into an impossible location. Do I need to check for myself if he's stuck? I noticed "avoidanceConsiderStuckedTime", should I check this manually?

    Thanks!
     
    vyshan likes this.
  47. small-U

    small-U

    Joined:
    May 10, 2013
    Posts:
    14
    I have a problem.
    upload_2019-3-29_19-54-10.png
    Agent SetDestination => to image Point, Should go to a nearby point,bug state

    green line: PolyNav2D
    yellow line: PolyNavObstacle
     
    Last edited: Mar 30, 2019
    vyshan likes this.
  48. vyshan

    vyshan

    Joined:
    Oct 20, 2018
    Posts:
    4
    I'm having the same issue, and when I invert de polygons on obstacles the MoveOnClick seems to not find a path around the obstacles
     
  49. vyshan

    vyshan

    Joined:
    Oct 20, 2018
    Posts:
    4
    Hello @nuverian
    I've setup the agents, the obstacles and the Nav polygon. The example attached shows the sprites flickering and getting stucked, on a space with wide room for moving.
    1. I've tried to invert the polygon on the obstacles, but besides not solving the issue, it also affected the MoveOnClick, and the pathfinding becomes incapable of targeting tiles behind the "Inverted obstacle"
    2. I've tried to use different shapes of colliders on the agents but it didn't change, after 30-40 seconds they start to get stuck until they are all stuck and flickering.
    any ideas?
     
  50. kylewill713

    kylewill713

    Joined:
    Jun 22, 2016
    Posts:
    5
    I am also having issues with agents getting stuck, attached is the code I used and here is video



    It doesn't happen all the time but it happens quite often.