Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Pathfinding in unity: First Path 1.0 tutorial now available!

Discussion in 'Made With Unity' started by AngryAnt, Mar 18, 2009.

  1. immortius

    immortius

    Joined:
    Aug 7, 2009
    Posts:
    41
    Suggestions for future versions:

    - Ability to delete a single path between waypoints (if a way exists I can't find it)
    - Warning prompt when AutoConnecting (because it is equivalent to wiping your existing network).
    - Ability to select waypoints in the scene (because it becomes troublesome finding them in the list).
     
  2. liverolA

    liverolA

    Joined:
    Feb 10, 2009
    Posts:
    347
    i hope there will be a solution for gameobjects (which walk as seeker) to avoid obstacles(and each other) when run on the path!
     
  3. Arges

    Arges

    Joined:
    Oct 5, 2008
    Posts:
    359
    You may want to look at UnitySteer:

    http://www.arges-systems.com/articles/35/unitysteer-steering-components-for-unity

    It has a PathFollower vehicle which you can extend for your obstacle avoidance needs, and an AngryAntPathway that you can initialize from a route obtained with Path.

    Cheers,
     
  4. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    daodao:
    As far as I know we don't have support for external assemblies in iPhone yet?

    liverol:
    UnitySteer is the "official" obstacle avoidance / steering bridge for Path. Anything steering related I do will go into that project and I'll keep the two compatible.
     
  5. fallingbrickwork

    fallingbrickwork

    Joined:
    Mar 16, 2009
    Posts:
    1,072
    Hi all,

    I am trying to intergrate Path within my current project and am 'hitting my head against a brick wall'.

    I have a PathCollection created with a waypoint mesh with nodes that are connected etc... all good so far. :D

    I am now trying to get a primitive cube to follow the waypoints and am having problems with the scripting. I have imported the editor example scripts (DemoSeeker and DemoControl) into my project and am trying to removing everything (gui's, autospawn, manual spawning, cameras etc) but this is leading to more errors than I can count. I have also tried stripping out the unwanted sections within the example project with similar results.

    So... (a massive pretty please, with some bells and a couple of cherries)...

    would anyone have a basic project which, when run, creates a cube which follows a few waypoints. no cameras, no gui, nothing outside of the sceneview?

    The tutorial is fantastic, as is the example project.. but, for me (maybe i'm the only one :oops: ), the scripting contains too much non-path info.

    Any help with this would be greatly received.

    Many thanks in advance...

    Matt.
     
  6. nintari

    nintari

    Joined:
    Jul 7, 2009
    Posts:
    100
    Checking this out-- I noticed that multi-selecting nodes doesn't seem to work in Windows. :/ Makes it a bit of a pain.

    PS- I would also appreciate a quick example project of a box following some waypoints as well.
     
  7. nintari

    nintari

    Joined:
    Jul 7, 2009
    Posts:
    100
    Actually I take that back... sometimes the multi-select will work in Windows and sometimes it won't. Have no idea why.
     
  8. fellipeml

    fellipeml

    Joined:
    May 12, 2009
    Posts:
    74
    Im looking for a way to unload these networks too. My game have various scenarios (each one with one navMesh) and it is getting too overloaded as i navigate trough them , slowing the path finder searches and "pausing" the execution of the game.

    There is no way to unload these networks loaded with Control.Instance.LoadCollection?
    Any way to reset the Control? Clear all buffered data?

    thanks.
     
  9. onemancrew

    onemancrew

    Joined:
    Jan 29, 2009
    Posts:
    14
    Hi,
    I'm having problem with the navmesh - my artist created a simple ground object with several holes in it. Now even though it's a low poly object I get thousands of way point in my nev mesh. I can't be certain but it appears that the navmesh generates several layers of nav points In different height.
    Any way to solve this ? Been through 2 artists so far but the problems presists.

    Guy
     
  10. cnsoft

    cnsoft

    Joined:
    Mar 18, 2009
    Posts:
    3
    @Mr angryant
    can you explain the property of democontrol and demoseeker.
    1)about democontrol
    toggleNetworkName: should I input the value manually?
    toggleNodeNames: should I input the value manually also?
    if i want my cube walk follow one waypointnetwork, i should set the variable toggleNetworkName value as my waypointNetwork name, is it right?

    2)about demoseeker
    Speed,TurnSpeed,TureEffect,Max Velocity Change Radius,Arrival Radius
    what's the meaninig of the variable???

    3) in demoseeker 's function Goto , it will return DemoControl's prdefined position when seek no path, how to set the positions? and why set these position
     
  11. ogrilion2

    ogrilion2

    Joined:
    Sep 11, 2009
    Posts:
    13
    Hey there Emil, I've been trying to implement your path classes for a few weeks now and I must admit I've gotten to the point where I'm a little stuck.

    I've tried to follow your demo code as far as possible and I think I understand most of it.

    Code (csharp):
    1. public void SetDestination(Vector3 aDestination)
    2.         {
    3.             Debug.Log("setDestination started");
    4.             if (seeker != null)
    5.             {
    6.                 seeker.Kill();
    7.             }
    8.             Debug.Log("transform position: " + transform.position + "destination: " + aDestination);
    9.             seeker = new PathLibrary.Seeker(transform.position,aDestination,maxFrameTime,radius,requiredTags,excludedTags,false,null);
    10.             Debug.Log("seeker created");
    11.             Debug.Log("Start: "+seeker.Start +" End: "+ seeker.End);
    12.             if (seeker.Start!=null  seeker.End!=null)
    13.             {
    14.                 Debug.Log("Seeker has start and end");                
    15.                 seeker.AddMonitor(this);
    16.                 Debug.Log("Monitor added");
    17.                 Control.Instance.StartSeeker(seeker);
    18.                 Debug.Log("seeker started");
    19.             }
    20.             Debug.Log("can has seekers (maybe)");
    21.         }
    22.  
    23.         public void OnSearchCompleted(Seeker aSeeker)
    24.         {
    25.             Debug.Log("OnSearchCompleted starts");
    26.             if (aSeeker != seeker)
    27.             {
    28.                 return;
    29.             }
    30.             path = aSeeker.Solution;
    31.             destination = aSeeker.To;
    32.  
    33.             if (path.Count == 0)
    34.             {
    35.                 return;
    36.             }
    37.             path.Insert(0, new ConnectionAsset(null, ((ConnectionAsset)path[0]).From, radius * 2.0f, ((ConnectionAsset)path[path.Count - 1]).Collection));
    38.             Debug.Log("seeker completed " + name);
    39.         }
    40.  
    41.         public void OnSearchFailed(Seeker aSeeker)
    42.         {
    43.             Debug.Log("Search failed start");
    44.             if (aSeeker != seeker)
    45.             {
    46.                 return;
    47.             }
    48.             seeker.Kill();
    49.             seeker = null;
    50.         }
    51.  
    52.         public void OnSeekerInvalidated(Seeker aSeeker)
    53.         {
    54.             Debug.Log("search invalidated start");
    55.             if (aSeeker != seeker)
    56.             {
    57.                 return;
    58.             }
    59.             path = null;
    60.             SetDestination(aSeeker.To);
    61.         }
    This class has been setup as a child of ISearchMonitor

    Code (csharp):
    1. using System;
    2. using System.Collections;
    3. using UnityEngine;
    4. using PathLibrary;
    5.  
    6.     [RequireComponent(typeof(Rigidbody))]
    7.     public class PCScriptV3 : MonoBehaviour, ISearchMonitor
    8.     {
    9.         String selected;
    10.         PathLibrary.Seeker seeker;
    11.         float maxFrameTime = 0.01f;
    12.         float radius = 3.0f;
    13.         ArrayList path;
    14.         Vector3 destination;
    15.         public string[] requiredTags, excludedTags;
    16.         float turnSpeedFactor = 0.0f;
    My Debug logs are telling me that the SetDestination function is running through fine and outputting reasonable looking data but none of the ISearchMonitor events are ever firing so the movment code in the update function never has the full path array to guide it.

    Any ideas why this might not be working as expected?
     
  12. Arges

    Arges

    Joined:
    Oct 5, 2008
    Posts:
    359
    Hello cnsoft,

    I'm not AngryAnt, but perhaps I can help in an oblique way. You may want to take a look at UnitySteer, and the AngryAntPathway and PathFollower vehicle:

    http://github.com/ricardojmendez/UnitySteer/blob/master/UnitySteer/AngryAntPathway.cs
    http://github.com/ricardojmendez/UnitySteer/blob/master/UnitySteer/Vehicles/PathFollower.cs

    PathFollower is a vehicle that follows a set path, while AngryAntPathway is creates a Pathway that PathFollower expects, based on the ArrayList of ConnectionAssets generated by AngryAnt's Path.

    Best,
     
  13. vitaliano-neto

    vitaliano-neto

    Joined:
    Oct 19, 2009
    Posts:
    20
    After a long time trying to make my custom Waypoint Network works, I found the differences between my Network and the Network in the demo: the radius of waypoints and the width of connections.
    Unfortunately my game don't have the same proportion of the demo, so my waypoints is much bigger than I need.

    And the question is, has any method to don't use the radius and the width as a decisive factor in the pathfinding?


    Thanks,
    Legionaryu
     
  14. vitaliano-neto

    vitaliano-neto

    Joined:
    Oct 19, 2009
    Posts:
    20
    Ok, I found the Radius property on seeker. The only thing that I have to do is set the radius to 0.1 and voilá.

    Thanks,
    Legionaryu
     
  15. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    I got such bad timing, just made some time to look at Path..but 2.6 seems to have changed some things.

    I hope a fix is up soon, in the meanwhile I'll have a look if I can fix this myself...
     
  16. damienthorn

    damienthorn

    Joined:
    Oct 1, 2009
    Posts:
    28
    Would like a fix too if it's possible...
     
  17. nikemerlino

    nikemerlino

    Joined:
    Jul 2, 2008
    Posts:
    66
    With 2.6 I have two problems:

    1) EditorUtility.FocusProjectView();
    I tried: EditorUtility.FocusProjectWindow();


    2)Assets/Editor/PathComponentEditor.cs(51,21): warning CS0114: `PathComponentEditor.OnInspectorGUI()' hides inherited member `UnityEditor.Editor.OnInspectorGUI()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword

    I cant' edit the script Path Control, I haven't the GUI
     
  18. prons

    prons

    Joined:
    Oct 29, 2009
    Posts:
    9
    You can just change that to 'public virtual'. Changing that and the FocusProjectWindow thing made it work on 2.6 for me.
     
  19. prons

    prons

    Joined:
    Oct 29, 2009
    Posts:
    9
     
  20. prons

    prons

    Joined:
    Oct 29, 2009
    Posts:
    9
    Hmm, more problems:

    MissingMethodException: Method not found: 'UnityEditor.Handles.PositionHandle'.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000]
    UnityEditor.SceneView.CallOnSceneGUI ()
    UnityEditor.SceneView.OnGUI ()
    PathComponentEditor.OnSceneGUI () (at Assets/Editor/PathComponentEditor.cs:140)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
     
  21. defmech

    defmech

    Joined:
    Feb 24, 2007
    Posts:
    506
    Been running into similar errors and warnings with Behave. Hopefully the fixes aren't too much trouble and AngryAnt can get it resolved soon. I have a prototype that needs to be done next Thursday and pathfinding is the biggest thing left to do :\
     
  22. defmech

    defmech

    Joined:
    Feb 24, 2007
    Posts:
    506
    We dug into this a bit today and managed to hit a dead end with the code quoted above by prons. In the UnityEditor.SceneView.CallOnSceneGUI, it is requesting the method OnSceneGUI on the Editor class via reflection. Using Reflector to examine this class, we have not been able to find an Editor.OnSceneGUI method. Are we mistaken? Was this method available in the previous UnityEditor version? It seems that at least SOME of the UnityEditor API has changed since the last version. I'm not even sure how much of this is AngryAnt and how much is a Unity thing.
     
  23. MadMax

    MadMax

    Joined:
    Aug 5, 2009
    Posts:
    203
  24. defmech

    defmech

    Joined:
    Feb 24, 2007
    Posts:
    506
    Yeah, we found that, but I can't really tell how it's actually being used by Unity. In Reflector, it doesn't appear anywhere in UnityEditor.dll(as a class unto itself) and not in the way it's being called by Path. The only instance I can find is inside the TerrainInspector and it looks like it's actually being defined within that class and not for the Editor as a whole. We're trying to find an old copy of the 2.5 files and see what difference, if any, there is.
     
  25. vileda

    vileda

    Joined:
    Jul 10, 2009
    Posts:
    15
    would be really nice to see a fix soon!

    anyway, great stuff!
     
  26. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
  27. bibbinator

    bibbinator

    Joined:
    Nov 20, 2009
    Posts:
    507
    Hello,
    The Path library looks like just what I need, but I'm wondering about the status?

    Are there any planned updates coming?

    Are there any tutorials like Behave has showing step-by-step how to setup Path in a new project? I saw the video "tutorial" movie, but it isn't really a tutorial it's more of a feature demo.

    Thanks,
    Brett
     
  28. the17706

    the17706

    Joined:
    Jan 3, 2010
    Posts:
    3
    Did #2 above get resolved for anyone? I even tried reconstructing the dll, and updating the files to Path 1.0.1 as found here --> http://github.com/MrJoy/Path-GPL , on the actual demo and still no luck. Also attempted a public override and also public new.

    My path control from the demo is missing several things that are shown in the pic below.
    http://eej.dk/angryant/wp-content/themes/angryant/images/PathGridNetwork.png

    Any help would be appreciated.
     
  29. JDonavan

    JDonavan

    Joined:
    Oct 3, 2009
    Posts:
    105
    You not only have to recompile the DLL you need to replace the script files in your editor folder as well. Namely: Assets/Editor/PathComponentEditor.cs
     
  30. the17706

    the17706

    Joined:
    Jan 3, 2010
    Posts:
    3
    I did that also...and still same result. As well as the Assets/Path folder including the PathControl.cs and the Assets/Editor folder including the PathComponentEditor.cs

    This was my result (Error):


    (Path Control):
     
  31. Arges

    Arges

    Joined:
    Oct 5, 2008
    Posts:
    359
    That's not an error but a warning, which means you can now run the application. If you read the message, it'll tell you how to get rid of it.
     
  32. the17706

    the17706

    Joined:
    Jan 3, 2010
    Posts:
    3
    Sorry, I meant a warning. Also I tried both public override and public new, both as stated in the warning. Lead to the same result. Running the demo project is not the issue, but the difference in path controls is. I can't even do what is done in the tutorial, I believe it's related to the warning. In the pic above on my previous post, I show the difference in the path control scripts. Mine and the one shown on angryants site.
     
  33. hjbaard

    hjbaard

    Joined:
    Feb 5, 2010
    Posts:
    38
    I have the same issues with Unity Pro 2.6.1f3 on a Windows XP machine.

    Anyone all ready fixed the problems?
    Or is there anyone who can tell me how to fix this?
     
  34. Davaris

    Davaris

    Joined:
    Jan 27, 2010
    Posts:
    68
    Yes do a search on AngryAnts Path in these forums. I was able to get it working on Win 7 and describe the process in the Path is open source thread.
     
  35. david.silva

    david.silva

    Joined:
    Feb 24, 2010
    Posts:
    3
    Hello everyone!


    I'cant edit the position of a waypoint on the Editor. I'm using the 2.6.1f3 version of Unity and the Editor Demo project of AngyAnt.

    MissingMethodException: Method not found: 'UnityEditor.Handles.PositionHandle'.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000]
    UnityEditor.SceneView.CallOnSceneGUI ()
    UnityEditor.SceneView.OnGUI ()
    PathComponentEditor.OnSceneGUI () (at Assets\Editor\PathComponentEditor.cs:143)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
     
  36. Davaris

    Davaris

    Joined:
    Jan 27, 2010
    Posts:
    68
  37. david.silva

    david.silva

    Joined:
    Feb 24, 2010
    Posts:
    3
    now i did! i get the last source code and compiled it.

    Thanks a lot! :)
     
  38. arioch82

    arioch82

    Joined:
    Dec 3, 2009
    Posts:
    253
    Hi all,

    just build the angryant one with the method wrote some post above, the editor seems to work (I'm just playing with it now for the first time) but I'm having an error in the console log (the number increment sometimes, it start with 1)

    Code (csharp):
    1. ArgumentException: Getting control 11's position in a group with only 11 controls when doing ExecuteCommand
    2. Aborting
    3.  
    4. UnityEngine.GUILayoutGroup.GetNext ()
    5. UnityEngine.GUILayoutUtility.BeginLayoutGroup (UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options, System.Type LayoutType) [0x00000]
    6. UnityEngine.GUILayout.BeginHorizontal (UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) [0x00000]
    7. UnityEngine.GUILayout.BeginHorizontal (UnityEngine.GUILayoutOption[] options) [0x00000]
    8. PathLibrary.Inspector.OnGUI (IInspector inspector)
    9. PathComponentEditor.OnInspectorGUI ()   (at Assets\Editor\PathComponentEditor.cs:94)
    10. UnityEditor.InspectorWindow.OnGUI ()
    11. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
    12. UnityEditor.GUIView:Internal_SendEvent(Event)
    13. UnityEditor.GUIView:Internal_SendEvent(Event)
    14. UnityEditor.GUIView:SendEvent(Event)
    15. UnityEditor.SelectedPPtrDropDownHolder:AssignPPtr(Object)
    16. System.MulticastDelegate:invoke_void_Object(Object)
    17.  
    what does it means?

    also the waypoint selection is always in "multiselection mode", there's a key to switch it off?

    attachment:

    I just compiled the latest original version and added the couple of modification needed by Unity 2.6.1 on Windows platform so that everyone can just download this.
    It still gives errors sometimes while editing but anyhow it works :)

    AngryAnt why don't you put this package directly on your website?
     

    Attached Files:

  39. Arno

    Arno

    Joined:
    Mar 10, 2010
    Posts:
    6
    newbie here...1 got the same problem as stated above (the17706).

    But i don't understand the replies on the post.

    Would somebody please explain it in sesemestreet language.

    http://screencast.com/t/NmYwOGU0Y


    how do i get angryants path to work!!!!

    PLEASE HELP!!
     

    Attached Files:

  40. DR9885

    DR9885

    Joined:
    Mar 13, 2010
    Posts:
    4
    There is a small compilation error with Using this library in Unity 3.0 and Up...

    SceneView.current.pivot

    should be changed to,

    SceneView.lastActiveSceneView.pivot

    ... I think...

    ~Daniel P. Rossi~
     
  41. tyler.kendrick

    tyler.kendrick

    Joined:
    Nov 20, 2010
    Posts:
    1
    Me and my fellow students are currently attempting to implement your "path" project into our senior project at college, and we were wondering if the upgrade to 3.0 has been made available yet? We really like the capabilities of your package, but we are currently required to use Unity 3.0 or above - so it seems we will not be able to use it.

    If you could provide suggestions on how to accomplish this upgrade ourselves, or post a 3.0/3.1 build of the "path" package, it would be greatly appreciated.
     
  42. RyuMaster

    RyuMaster

    Joined:
    Sep 13, 2010
    Posts:
    468
    I want to make Path working with Unity Steer. But I can't make path compile with Unity 3.1, some errors with the editor I beyond scope of my understanding. Anyone managed to get Path working with Unity 3.1 already? Is it much of work?
     
  43. ClandestineMan

    ClandestineMan

    Joined:
    Jul 16, 2010
    Posts:
    17
    I am having the same issue. Path works great when setting up paths and networks and stuff, but when it comes time to compile our game, we get the error below and no exe file to run. Anyone have any idea what the issue is or how to fix it? I have tried using the package from AngryAnt.com, and both GPL version with no luck.


    ArgumentException: The Assembly UnityEditor is referenced by Path. But the dll is not allowed to be included or could not be found.
    UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2 cache) (at E:/BuildAgent/work/71ca6fec1b41cc30/Editor/Mono/AssemblyHelper.cs:52)
    UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2 cache) (at E:/BuildAgent/work/71ca6fec1b41cc30/Editor/Mono/AssemblyHelper.cs:55)
    UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch) (at E:/BuildAgent/work/71ca6fec1b41cc30/Editor/Mono/AssemblyHelper.cs:86)
    UnityEditor.HostView:OnGUI()
     
  44. RyuMaster

    RyuMaster

    Joined:
    Sep 13, 2010
    Posts:
    468
    I managed to workaround it. Have 2 copies of Path.dll
    One normal.

    Another - for when you build it.
    In "another", remove UnityEditor from references, and all relevant code parts (they will bring Editor, but who needs editor in compiled game?)

    This way, you can have it working.

    'Course, you need to use fork-build which has Editor patched for Unirt 3.1