Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

Unity Path Finding

Jarrod1937Jarrod1937 ✭✭✭
edited May 2016 in Questions And Answers

Well, after getting my Hololens and finally attempting to push my code though, I found that the Apex path finding code does not work with the UWP :-(
In order to save myself time in the future, does anyone know if there is a path finding solution for Unity that works with UWP and the Hololens? I'm sure I'm not the only one who needs path finding, especially premade to save time.

Best Answer

Answers

  • Options
    Jimbohalo10Jimbohalo10 ✭✭✭
    edited May 2016

    What about asset store https://www.assetstore.unity3d.com/en/#!/content/26566
    Path Map Generator! The description is good, if its about maps for characters motion
    Type "path" and select free in Unity Asset Store
    There is so much of path generators. I suppose C# could be true in most cases they probably wont link to HoloLens library, and what so of code could test the package

  • Options
    Jarrod1937Jarrod1937 ✭✭✭

    Unfortunately, that is not advanced enough for what I need. Currently I am using this:
    https://www.assetstore.unity3d.com/en/#!/content/17943

    Which uses A* and grid graphs that can be generated at run time. This way I can tell an object/agent to go from point A to point B and it will find a path around any obstacles, rather than attempt to simply walk straight through. Path finding is generally the most basic level of any AI that needs to move around the environment.
    Unity supports nav meshes, but you cannot generate it at run time. I used Apex path finding, the asset linked above, but it seems to be heavily reliant on non-UWP .NET libraries, and generates hundreds of errors when exporting the project to Visual Studio to load on the Hololens.

  • Options
    Jimbohalo10Jimbohalo10 ✭✭✭

    Even when you find a package A* path like https://www.assetstore.unity3d.com/en/#!/content/1876
    You find its 5.1 and although it says 5.1 and above, its not!

    The generated code will rely on net 2.0/3.5 and there is no way to update the code, to generate by Unity .NET 4. Which explains why so many games rely on old Unity versions

  • Options
    Jarrod1937Jarrod1937 ✭✭✭

    Ah, that's excellent news indeed! I will check that out for sure. Thanks for testing it, a lot of my code was intertwined with Apex, but shouldn't be too much work to get things going.

  • Options
    Jarrod1937Jarrod1937 ✭✭✭

    @Jimbohalo10 , did you have to do anything special to get the path finding to work for the dynamic spatial mesh? I haven't taken a look at it yet, but I will be working on it this weekend and am just curious. It looks like it's default behavior is at runtime, which is perfect, just as long as I can control when it does it (after the spatial mesh is generated and processed into planes).

  • Options
    Jimbohalo10Jimbohalo10 ✭✭✭
    edited May 2016

    @Jarrod1937 My initial porting setting are always the same build Player Windows Store, Universal 10,XAML,Local Machine, Unity C# then with Visual Studio 2015 Community
    "Master,x86,Local Machine", Build
    Followed by
    "Debug,x86,HoloLens Emulator", Build
    Build -> Deploy Solution,
    Debug -> Start Debugging

    I have now tried "DynamicTDScene" and this fails due to script Ghost missing
    If you delete the Ghost Game-Object entry then Unity spits out an error as well as VS 2015 "Game Object missing"

    WayPoint still works fine, GridScene is amazing the Red goes to find Blue over the bridge and Red try's to run from Blue, but cant Blue just chases Red back over the bridge!.
    An its working in HoloLens Emulator, just have to fiddle with the inputs, but chase works!

  • Options
    Jarrod1937Jarrod1937 ✭✭✭
    edited June 2016

    Alright, reached the point where I'm going to try and implement this path finding solution. The guy's code is very nicely laid out, and seems to be designed from the ground up to be generated at runtime. Not ideal for most things, but certainly ideal for us Hololens users!
    To not make the same mistake again, I'll start with a simple test and have it path find to chase the player, then I'll build it up from there.

  • Options
    Jarrod1937Jarrod1937 ✭✭✭

    Alright, I think I got it to work with the spatial mesh. I'm taking the spatial mesh, doing plane finding, attaching a box collider to the floor planes via script (took a while to figure this out), generating the grid, and then instantiate a simple enemy (a capsule... nothing fancy, haha). I did a few other things to trim down the example AI script to the bare minimum. It's also important to assign enemies and the player to the ignore tags list, otherwise the enemy will spawn directly in the middle of a no-go zone and it doesn't move.

  • Options
    Jarrod1937Jarrod1937 ✭✭✭
    Update #2, while it seems to be pathfinding, the code acts just like me telling it to follow me without path finding. My test capsule runs through walls and table planes. After further investigation, I realized I needed to add box colliders to those planes as well. However, it still doesn't work. Through testing and looking at the code, in the mesh to plane processing plane thickness I have set to 0.2, and from what I can tell this is too thin to be picked up by the grid graph. My solution is to check the mesh bounds to find the thinnest bound dimension (x,y,z) and set that dimensions box collider bound to 35 (figure found from testing). This seems to make the bounding boxes dimension, relative to the meshes 0.2 thickness, large enough to be picked up by the default grid graph tile size of 1. I've considered decreasing the tile size to get better resolution but I'm wanting to avoid that for performance reasons.
  • Options
    Jarrod1937Jarrod1937 ✭✭✭

    I am making further progress. It works perfectly in the Unity Editor doing testing, it behaves somewhat differently in the Hololens with the planes generated, seems less precise for some reason. It will cleanly mark tiles as not walkable in the Editor. In the Hololens, instead of making the border of a wall unwalkable, it makes a few feet into the border of the wall unwalkable. I'm wondering if the box collider of the plane prefab is resizing with the scaling I'm using in code. I made a few changes to the code:

    • I created a public function for generating the map, the generation function is no longer called on start.
    • I removed the start and end position public variables. I replaced these simply with a size (Vector2) public variable. This way you can say I want a 15x15 (~50x50 ft) grid graph generated, and it will now generate it around the players position, instead of an arbitrary start and end position defined by the dev.
    • I made a simple change to the editor lines function. This function is intended to allow you to see what it is defining as walkable in the editor. I removed it's call per frame update and inserted it after the generate map function call. This now takes a prefab, 1x1 in size, and places it at the grid points. The prefab is then scaled by the tile size factor. This allows me to then see what it is defining as walkable within the Hololens in person.

    I want to move on past this and work more on the fun bits of my game, but I'm trying to get this running fairly smoothly before moving on. Once I've figured out all of the little tricks to getting it to work properly I'll share that info for others needing path finding in the future.

  • Options
    Jarrod1937Jarrod1937 ✭✭✭

    Here's a video showing my progress on the path finding:

    https://www.youtube.com/watch?v=t1q_P0VF6dc

  • Options
    Jarrod1937Jarrod1937 ✭✭✭

    Breakthrough! I still have an issue where the doors are covered by the wall planes (even doing subplanes), but I managed to augment the main plane grid graph generation with the spatial mesh. For this I used the spatial mapping collider script, but the tricky part is that in the path finding code I need to define the min and max sampling height for the graph generation. For this, I do plane finding first, I get the floor height (lowest plane marked as a floor), I then pass this height as the lowest height value, and use this value plus 1.8 meters (roughly 6 feet) for the maximum height value. This allows the grid graph to capture details of the room while avoiding the ceiling as a component in the calculation. I still require using the walls, as my guy will happily walk through a wall with only the spatial mapping, but the two combined work fairly well. I'm happy enough with it now I can post a video of the progress and move on to more exciting aspects.

  • Options

    @Jarrod1937 : thank you for sharing your progress.

    For my project I also need to use pathfinding on the Hololens for a digital character to navigate through the physical space, and I'm playing around with A* right now.

    Any chance you'd be willing to share your work in form of a step by step tutorial? =)
    (I couldn't find anything on wikiholo.net yet)

  • Options

    I used the layered grid graph and directly the spatial mesh without generating planes as you did. It kinda works, no problemo with the walls.

    What I am struggling with is generating off-mesh links. In one of the demo scenes there are those animation links.

    Unfortunately, to make a star work on the hololens I had to do this: http://forum.unity3d.com/threads/a-pathfinding-failed-to-run-serialization-weaver-when-building-for-windows-store-wp8-1.377737/
    After doing that this demo scene doesn't work anymore; not in the editor and not on the hololens.

    Any ideas on how to make the character jump on and off the table?

  • Options

    A* has been updated a few times and I just downloaded the newest free version and with a minor change it seems to work fine with my holographic app.

Sign In or Register to comment.