Giter Club home page Giter Club logo

navmeshplus's Introduction

NavMeshPlus

NavMeshComponents.Extensions provides you with ability to create navigation meshes that are generated automatically from your Scene geometry, which allows characters to move intelligently around the game world.

NavMesh

Unity 2D Pathfinding

This repo is fork of Unity NavMeshComponents enhanced with Extensions system for 2d Pathfinding and more. [link]

Wiki [here]

How To [here].

Demo [github].

Discuss [unityforum].

2D NavMesh

In repo you will find implementation of NavMeshSurface and 2d Extensions for tilemap, sprites and collider2d top down games.

To use it in your project:

  1. Copy repo into your Asset folder (or install as a package).
  2. Create Empty Object in scene root.
  3. Add "Navigation Surface" component to Empty Object and add NavMeshCollecSources2d component after.
  4. Click Rotate Surface to XY (to face surface toward standard 2d camera x-90;y0;z0)
  5. Add "Navigation Modifier" component to scene objects obstacles, override the area.
  6. In "Navigation Surface" hit Bake.

How does it works:

  1. It uses NavMeshSurface as base implementation.
  2. Implements world bound calculation.
  3. Implements source collector of tiles, sprites and 2d colliders
  4. Creates walkable mesh box from world bounds.
  5. Convert tiles, sprites and 2d colliders to sources as NavMeshBuilder would do.

Components & Extensions:

  • NavMeshLink
  • NavMeshModifier
  • NavMeshModifierVolume
  • NavMeshSurface:
    • NavMeshCollectSources2d
    • NavMeshCollectRootSources2d
    • NavMeshCacheSources2d

Utilities

  • NavMeshExtensionsProvider.cs
  • NavMeshBuilder2d.cs
  • NavMeshExtension.cs
  • NavMeshBuilderState.cs

Setup

You can use this in two different ways: downloading this repository or adding it to your project's Package Manager manifest. Git must be installed and added to your path. Alternatively, you can pick scripts and place in your project's Assets folder.

Method 1. Download

Download or clone this repository into your project in the folder Packages/com.h8man.2d.navmeshplus.

Method 2. Package Manager Manifest

The following line needs to be added to your Packages/manifest.json file in your Unity Project under the dependencies section:

"com.h8man.2d.navmeshplus": "https://github.com/h8man/NavMeshPlus.git#master"

Method 3. Add Package form git URL

Go to Package Manager click + and then select Add Package form git URL paste url:

https://github.com/h8man/NavMeshPlus.git

navmeshplus's People

Contributors

axha avatar codxr02 avatar colinbellino avatar h8man avatar harrisonhough avatar jl-randazzo avatar mitay-walle avatar rhys-vdw avatar rouux avatar snarlynarwhal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

navmeshplus's Issues

Weird navmesh artefacts

I have weird navmesh artefacts. You can see them in the screenshot. I managed to fix them by adding a quad rotated (90, 0, 0) and referencing it in Use Mesh Prefab setting of the NavMeshSurface2d. I don't understand why this fixed the problem, but somehow it worked.

But for me this solution feels like just a workaround. I think there should be no artefacts in a first place.

P.S.: thanks you very much for such a great tool

artefacts
no artefacts

Missing steps

This is the setup needed for tilemaps to be recognized.
Add this to your readme.md

image

Setting agent.velocity doesn't do anything if x=0

Encountered this trying to add WASD type movement - agent will only move if velocity.x has a non-zero value.

Using this code:

` var horizontal = Input.GetAxis("Horizontal");
var vertical = Input.GetAxis("Vertical");

    if (horizontal != 0 || vertical != 0)
    {
        var direction = new Vector2(horizontal, vertical);
        agent.ResetPath();		 
        agent.velocity = direction * agent.speed;
    }`

Pressing up&right together works, just right/left works, just up/down fails.

Does not show result mesh correctly in prefab mode.

Hello
My stages are saved in prefabs.
I could bake the mesh correctly in prefab mode but it won't show the result unless I am viewing the mesh from a normal scene with the prefab. This issue make it a little hard to evaluate mesh result right after baking. It would be very appreciated if this can be improved.

Thanks for the excellent work.

Error after updating to Unity 2018.3.0

I just upgraded my Unity install from 2018.2.16 to 2018.3.0 this morning and on opening my project I received the following warnings and error:

Assets/NavMeshPlus/NavMeshComponents/Scripts/NavMeshSurface.cs(371,30): warning CS0618: 'PrefabUtility.GetPrefabType(Object)' is obsolete: 'Use GetPrefabAssetType and GetPrefabInstanceStatus to get the full picture about Prefab types.'

Assets/NavMeshPlus/NavMeshComponents/Scripts/NavMeshSurface.cs(372,31): warning CS0618: 'PrefabType' is obsolete: 'PrefabType no longer tells everything about Prefab instance.'

Assets/NavMeshPlus/NavMeshComponents/Scripts/NavMeshSurface2d.cs(465,30): warning CS0618: 'PrefabUtility.GetPrefabType(Object)' is obsolete: 'Use GetPrefabAssetType and GetPrefabInstanceStatus to get the full picture about Prefab types.'

Assets/NavMeshPlus/NavMeshComponents/Scripts/NavMeshSurface2d.cs(466,31): warning CS0618: 'PrefabType' is obsolete: 'PrefabType no longer tells everything about Prefab instance.'

Assets/NavMeshPlus/NavMeshComponents/Scripts/NavMeshSurface2d.cs(470,26): error CS0039: Cannot convert type 'UnityEngine.AI.NavMeshSurface2d' to 'UnityEngine.AI.NavMeshSurface' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion

Updating navmesh at Runtime

Good afternoon!

Firstly I just want to say thank you for this great tool!

I'm attempting to generate a bunch of boxes at run time, Before run time, if I place a Navmesh obstacle on the boxes and hit carve, the boxes carve out their area in real time, The same thing happens if I bake the navmesh.

But if I try to create the boxes at run time, Even if they have the Navmesh obstacle set to carve, the navmesh still generates over them. Is there something I need to do to get it to update with the generated boxes?

I'm 99% sure this is my lack of knowledge of the navmesh system in general.

Any help would be appreciated
Thanks!

`GetRoot` fails with `NullReferenceException` when scene has no Grid

return new[] { GameObject.FindObjectOfType<Grid>().gameObject };

This line throws when using a NavSurface2d set to CollectObjects2d.All without a Grid object. A Grid is not required when using colliders. It seems as though CollectOptions.Children is the only option compatible.

Also, if you do add a grid at the root of colliders, it complains "NullReferenceException: Add at least one tilemap", rather than simply scanning its children for colliders.

I think it should be pretty straight forward to either 1. scan the whole scene for geometry, or 2. fix these errors by preventing invalid configurations in the inspector.

Why is a 1x1 tile not detected as walkable?

image
As in this picture, 1x1 tiles that are closed on all sides are not detected.

image
I tried changing the radius, but the result is the same. Why is this 1x1 tile not detected as walkable?

Weird NavMeshAgent behaviour when disabling rotation and upaxis

Hey,

so for some reason the agent doesnt want to avoid the non walkable areas, despite having a valid navmesh.
Basically what im doing is, setting a destination that is below the object on the Y axis. It starts moving but then gets stuck on the non walkable areas.

Gif: https://imgur.com/8fhpCmE

If i enable back rotation and upaxis it rotates properly around the object, but it messed up everything :D because the navmeshagent doesnt understand its on a 2d plane :)

Any clues how to solve this?

Sprite with Polygon Collider 2D doesn't work with NavMeshModifier

Hello, first of all thanks for the script!

Context

The issue I have is that I have a big sprite for a building that uses a Polygon Collider 2D component because its collision does not exactly match its shape.

Issue

Description

I tried adding a NavMeshModifier component to the sprite, and setting it to override Not Walkable, but it is not being cut from the mesh.

Steps to reproduce

  1. Create a tile grid with walkable areas
  2. Create a new GameObject with a
    • Sprite Renderer, scale the sprite to be big, several tiles large
    • PolygonCollider2D, give it a shape so the player can walk on some part of the sprite
    • NavMeshModifier, set to override "Not Walkable".
  3. Create a new GameObject with a
    • NavMeshSurface2d, have the "Default Area" be Walkable and set "Use Geometry" to Physics Colliders
  4. Bake the nav mesh using the NavMeshSurface2d

Expected results

The PolygonCollider2D bounds should be cut from the baked NavMesh

Actual results

Nothing is cut from the NavMesh.

Workarounds

One workaround is to use several Nav Mesh Obstacles to approximate the collision shape, but I'd really prefer to use the more flexible Polygon Collider 2D because of the complex shape and out of some concern for performance.

Potential Bug Source

I think the issue arises because NavMeshPlus detects the NavMeshModifier is attached to a sprite and tries to use the sprite vertices before checking for any colliders on the GameObject.

Thanks

Thanks again for the script, please let me know if you need any more information.

Not working on TilemapCollider2D

Hello, iam using this and there is no "Grid" Option (Collect Objects) like the Tutorial say.
Iam using a Tilemap2DCollider and it not working. I followed the tutorial

Multiple grids in scene

Hello.

I have been using NavMeshPlus in the development of a Roguelike/RPG with pseudo-random, procedurally generated areas. Each area is composed of multiple "rooms", each with different elements and tilemaps. These rooms are made using the Prefab system in Unity, with specific components (such as containers or enemies inside the room) being randomly generated afterwards.

The problem is as follows: in order to use the Prefab Editor in Unity (which is a necessity to comfortably modify the room prefabs), the tilemaps need to have a parented Grid, or they aren't properly displayed. The easiest solution to this problem is to have a grid in each room prefab. After quite a bit of work with the prefabs, I found out that the NavMeshSurface2d didn't generate the correct surface: it ignored every other grid in the scene except the first one it found, and so it generated only the NavMesh for one room.

I took a look into the tool, and saw that in the lookup for grids in the scene (GetRoot function in NavMeshBuilder2d), even though an array of GameObjects is being returned, it will always contain only the first grid it finds:

     switch (CollectObjects)
     {
            case CollectObjects2d.Children: return new[] { parent };
            case CollectObjects2d.Volume: 
            case CollectObjects2d.All: 
            default:
                return new[] { GameObject.FindObjectOfType<Grid>().gameObject }; // Only returns one grid
     }

For my particular problem, I fixed it by changing that last line as follows:

            default:
                List<GameObject> grids = new List<GameObject>();
                foreach(Grid g in GameObject.FindObjectsOfType<Grid>()) {
                    grids.Add(g.gameObject);
                }
                return grids.ToArray(); // Returns all gameObjects with a Grid

I tested it with several rooms (all of them relatively large in size) and the surface looked like it was being created properly.
There probably are a few other solutions to my specific problem, but this works for now. Was there any reason for the original line?

Issue with unity .Net 4.x default literal

Hey there,
keep getting an error when trying to use these scripts in NavMeshBuilder2d and NavMeshSurface2d because apperantly they are using default literals which is not working for some reason

Small obstacle avoidance radius stops pathfinding

In an effort to try and stop agents bumping into each other and getting stuck, i've tried lowering the obstacle avoidance radius - but anything below 0.3 stops pathfinding from occuring.
My end goal is to get agents being able to use the same space for navigation - but feel like i've come unstuck trying to get this working. To smaller avoidance radiance and the bottom seems to fall out on 2d pathfinding...

l was wondering if this had something to do with where the agent sits vs. where the nav mesh is, and the agent is perhaps not considered 'on the navmesh' if he has too smaller radius...

Proposal: BuildNavMeshAsync

I need to build a navmesh asyncronously at runtime. Although NavMeshBuilder exposes no BuildNavMeshDataAsync it's quite trivial to implement via this method.

I would like to add AsyncOperation NavMeshSurface2d.BuildNavMeshAsync() for this purpose.

Would you be interested in a PR adding this feature?

About NevMeshData property disabled in NavMeshSurface2D

I don't know why but NevMeshData property is disabled in the NavMeshSurface2D inspector. It would be great if I can click it and found it in project panel so that I can rename or even move them accordingly based on the stage I am editing. e.g. Either by making it enabled or simply add an inspector button to ping and select the object in the project panel.

Thanks for reading.

nullref

Thanks for making this available publicly.
Following the repro steps in a 2d project on 18.2, upon pressing BAKE I get this error:

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.AI.NavMeshSurface2d.CollectSources () (at Assets/NavMeshComponents/Scripts/NavMeshSurface2d.cs:290)
UnityEngine.AI.NavMeshSurface2d.UpdateNavMesh (UnityEngine.AI.NavMeshData data) (at Assets/NavMeshComponents/Scripts/NavMeshSurface2d.cs:174)
UnityEditor.AI.NavMeshSurfaceEditor2d.OnInspectorGUI () (at Assets/NavMeshComponents/Editor/NavMeshSurfaceEditor2d.cs:312)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1367)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Not including 1-tile-wide passages

When using this and everything is going correctly, it does not include the one wide gaps between walls and i couldn't find any documentation on this. Is this intended or is there a spacing setting i missed?
Using unity version 2019.2.5f1 and NavMeshPlus version 0.1.0
I'm an idiot and didn't look in the right place. Sorry for being noob! Cheers!

Tiles with ColliderType.None are included in obstacles (sources)

I'm using ColliderType.Grid for wall tiles and navMesh is building for them correctly. But I also use ColliderType.None for decoration tiles which are not obstacles like grass or bushes or decoration continuation (like spikes) of wall tile in neighbor cell.

But CollectTileSources() method includes such tiles in sources.

Of course, I probably should keep such tiles in separate tilemap to avoid redundant iteration. But anyway, adding ColliderType.None tiles into sources feels wrong.

NavMeshAgent - Invisible Sprite

Hello!

I am new to game development and am working on a top-down 2D adventure game in Unity. I am attempting to use NavMeshPlus for my enemy pathfinding, but I am running into an issue of disappearing sprites.

The issue arises when I add a NavMeshAgent component to my enemy game object. The sprite will be visible within the "Scene" view, but as soon as I move into the "Game" view the sprite disappears.

The NavMesh itself works well and seems to pick up on all of my collision tiles after baking, but I haven't been able to find any fixes for the disappearing sprites online. Hoping you'll be able to help. Thanks!

image

image

Navmesh holes when using changing "cell swizzle" & tilemap orientation

Steps to reproduce:

  • add a Grid
  • set swizzle to XZY
  • Add 2 tilemaps to the grid
    • make one the ground, adding navmesh modifier and overriding the area to "walkable"
    • make the other one the walls, adding navmesh modifier and overriding the area to "unwalkable"
    • set both tilemaps' orientation to xz
  • add a NavmeshSurface2D to an empty object
  • set up the agent size etc
  • bake

Issues:

  • while the navmesh is correct for the indoor walls, there's a gap between the indoor area and the outdoor area, disallowing agents to enter/exit the building (see first image below)

image

The issue does not appear when the swizzle & tilemap orientation settings are left at their defaults. (see image below)

image

Specs:

  • Unity 2020.2.1f1
  • NavMeshPlus: latest (from Git)

Using NavMeshSurface2d changes z position of an agent moving on the navmesh

I have a player gameobject placed on a navmesh with NavMeshSurface2d rotated -90 on X just like the WIKI says. When the "game" starts the z of the transform holding the player gameobject is set to --0.7708252.
The runtime navmesh generation works, colliding works, agent.SetDestination works.
Manual movement (keyboard arrows) don't work, the player object get's stuck from time to time when moving up or down, probably to the Z missmatch.
As a workaround I have code in the update to set the Z to 0 whenever it's not (the value is getting set to the -0.7708252 constantly actually), but that results in some other issues and just feels bad.

Using NavMeshSurface doesn't generate the issue, but of course doesn't work for the 2d case anyway so quite hard to say if it's really NavMeshSurface2d but I have been randomly disabling components and that's my best bet now.

Let me know if you can help and if I can provide any more clues here.
Cheers

When setting the transform.position, it breaks the pathfinding.

I am using NavMeshPlus to guide a wizard enemy towards the player. It works great except when he teleports. To teleport, he sets his transform.position to his destination. This causes the pathfinding to malfunction, though.

I am not sure if this is related but if the wizard collides with a Rigidbody2D, he fixes himself. The Wizard also has a Rigidbody2D and BoxCollider2D.

"How to" improvements

Hello,

As a newbie Unity dev, I found this tool very useful.

One quibble that was frustrating, however, was that the How-To guide is a PDF, which means that within GitHub (where I guess most people will read it) the text is not selectable or searchable (via Ctrl+F).

Is there a reason for this? And if not, would you be open to reworking it into standard markdown? I would be happy to help, if so. Additionally, I believe you are a non-native English speaker, and I think there are a number of things that could be phrased more clearly, if you would be open to letting me rejigger some things there, too?

The biggest downside is that I'm a really amateur Unity dev, so I think there are some fundamental concepts I may be misunderstanding in your explanation, and it may require you to answer some dumb questions on my side. :(

Thanks so much for the great lib.

Z coordinate of tiles is ignored

Looks like you completely ignoring Z coordinate of tiles.

I'm making a top-down 2D game. Despite it's in 2D, it's in Top-down Oblique projection, so it uses Z ordering for character to be able to stand behind a rock or behind a tree, for example. So, position of each tile is = Vector3Int( x, y, y ). But NavMeshBuilder2d.CollectTileSources() method iterates only through X and Y axes.

I managed to fix it by adding iteration over Z axis in CollectTileSources() method and setting Override Vector to (1, 1, 0). I don't understand what Override Vector is. It was just a guess. But it worked.

I hope you will add iteration over Z axis, so I can use your great tool without my own modifications.
Cheers

NavMesh generated over non-existent tiles

Hi, thanks for this great asset. I recently noticed a bug where NavMesh would be generated in places where tiles don't exist. Steps to replicate:

  1. Set up tilemap as per how-to guide
  2. Select single tile or filled box brush
  3. Paint with shift key selected (i.e. remove tiles) anywhere on the tilemap where there's no actual tiles
  4. Bake the NavMesh

This is the result in my case (note that the green-isn area contains tiles beneath it and the blue area doesn't - that's where I removed tiles):

image

Please let me know if you'd like me to provide any additional information.

Using This For Commercial Project [Question]

Hi,

Firstly thank you for this asset, it is a life saver and has helped me do a lot for my project.
Just wanted to ask, I did read your licence but wanted to clarify, is there no issues of using this for a commercial games project, would you like credits or anything?

Thanks!

Unity editor Bake functions differently to scripted break.

I'm developing some 2D isometric world generation logic using NavMeshSurface2d and NavMeshModifer scripts. So far, all the tile colliders have worked ok when baked with the script (calling NavMeshSurface2d.BuildNavMesh).

However, when adding a GameObject to the mix which has it's own polygon collider, the script call to bake the mesh does not include the gameobjects' colliders. When I generate the world, then press bake from the UI the colliders are baked fine.

Is there a reason it would work from the GUI but not scripted? Could it be a timing issue? Do I need to 'construct' the colliders somehow?

Inaccurate baking

Hey! I've setup your NavMeshPlus, but I have problem as you can see on screen:

image

Mesh is really inaccurate. I have 3 tilemaps. Ground, OnGround and Objects. Objects are marked as not walkable. I didn't make any extra steps. Object tilemap has tilemap collider with composite collider.

Could you help me? What can be reason?

NavMeshSurface2D editor not rotated correctly

I lost a few hours when I accidentally unrotated my NavMeshSurface2D:

Name your new empty GameObject, name it "NavMesh", and rotate it -90, 0, 0.
https://github.com/h8man/NavMeshPlus/wiki/HOW-TO#nav-mesh-plus

Some ideas for improving this:

  • Show a warning in inspector when the object is incorrectly rotated.
  • Provide a prefab object for the nav mesh surface that has an additional script that forces it to be rotated correctly.
  • Ignore object rotation when generating a surface (if possible/appropriate)

I'd be open to contributing this change.

AI Jittering/Not moving - [Issue]

Hi,

Sorry about this, I am getting a weird issue with the asset.
I have a tilemap world, I have baked the navmesh and it's baked nicely, and the AI do move.

However the AI tend to get stuck every now and then and won't move, sometimes they start moving once the player moves or if I just leave it long enough, but I have no idea why this happening.

I have attached some images of:
How the baked navmesh looks
What seems to be occurring

Will also include the code of my AI:
AI can wander around randomly
AI can patrol by moving towards patrol points.

Thanks

Nav Setup

AIGif

Above Gif is not representative of the framerate in-game, everything runs smoothly in-game except for the movement

private IEnumerator PatrolAround()
    {
        while (patrol)
        {
            if (patrolPoints.Count > 0)
            {
                agent.SetDestination(patrolPoints[patrolIndex].position);
                //if (transform.position == patrolPoints[patrolIndex].position || Vector3.Distance(transform.position, patrolPoints[patrolIndex].position) < 0.142f)
                //{
                //    //Debug.Log(Vector3.Distance(transform.position, patrolPoints[patrolIndex].position));
                //    patrolIndex++;
                //}
                yield return new WaitUntil(() => Vector3.Distance(transform.position, patrolPoints[patrolIndex].position) < 0.142f);
                patrolIndex++;
                Debug.Log("Made It");
                if (patrolIndex >= patrolPoints.Count)
                {
                    patrolIndex = 0;
                    
                }
                
                yield return new WaitForSeconds(1f);
               
            }
        }
    }
public IEnumerator WanderAI()
    {
        while (wanderAround)
        {
            Vector3 newPos = RandomNavSphere(transform.position, maxDist, -1);
            agent.SetDestination(newPos);
            if (Vector3.Distance(transform.position, newPos) != Mathf.Infinity) //sometimes the distance is infinity - not sure why
            {
                yield return new WaitUntil(() => Vector3.Distance(transform.position, newPos) < 0.142f);
            }
            yield return new WaitForSeconds(1f);
            //Debug.Log("Woo");
        }
        
    }

public static Vector3 RandomNavSphere(Vector3 origin, float dist, int layermask)
  {
    Vector3 ranDir = UnityEngine.Random.insideUnitSphere * dist; //finds a random vector in a sphere distance
        
    ranDir += origin; //adds current pos to that pos
       
    NavMeshHit navhit;
        
    NavMesh.SamplePosition(ranDir, out navhit, dist, layermask); //finds the closest point on navmesh within range, layermask will be -1 as that means all layers
        
    return navhit.position; //return the random position
}
```

Dynamic obstacles

Hi, sorry if this question is silly (i am newbie in unity)

Is this mesh support dynamic obstacles?

Generating navmesh at runtime

Is it currently possible to generate a navmesh at runtime, and if not, is this because it would be difficult to do?

Also, unrelated, how can I set the size of the scanned area? My game has no tilemap and there seems to be no way to directly set a grid's width and height. I've resorted to adding a grid and tilemap with corner tiles and its renderer disabled.

Thanks!

Programmatic build nav mesh uses previous build

Hey again @h8man!

Running into another issue and probably doing something wrong, but wanted to see if you've seen this scenario:

We've been randomly generating our tilemap and then programmatically calling the NavMeshSurface2d.BuildNavMesh() using a custom GUI Editor button on our component that generates the level and builds the NavMesh. We had some issues at first, but as you may recall in #41 we were able to resolve them.

Now that we're happy with our random level generation, we'd like to do it at the start of the scene when playing. Our level generation works and the BuildNavMesh() sort of works. It builds the nav mesh, but it doesn't use the same NavMesh data file, and for some reason though the NavMesh that is applied is the one that was last generated programmatically via our custom GUI Button.

I suppose the important thing to keep in mind is that whether or not you press the our GUI button to generate the level or start the scene to generate the level, the same exact code is being called.

Here are some screenshots - hoping you my have some suggestions on where to start investigating:

Pressing our Custom GUI Generate Level button works as intended:
image

After pressing Play a new level generates, but it using the previous generated NavMesh (notice the Nav Mesh Data is just called NavMesh now though):
image

After stopping the scene, our tilemap will revert to the last level we had generated outside of play mode (this is normal) and of course it's Nav Mesh Data is back to NavMesh-NavMesh
image

And the file NavMesh-NavMesh does actually exist:
image

Documentation - Use Geometry Physics Collides

I am using the Unity Isometric Tilemap example and trying to convert that to use your navmesh system. In the demo, they use Decorations which use physics colliders.

How do I go about doing this as I saw that you could do use geometry physics colliders, but can't get it to work?
Am I also not sure how I could get physics colliders and tilemap working alongside each other as the demo uses for building the world?

navmesh going through tiles

When the agent radius is set to 0.3 the navmesh goes through tiles even though composite colliders are water tight
image

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.