Giter VIP home page Giter VIP logo

navmeshsurface2dbaker's Introduction

NavMeshSurface2DBaker

About

NavMeshSurface2DBaker is a Unity Package that provides functionality to bake 2D colliders into NavMeshSurfaces, which are part of the Unity NavMeshComponents.

Prerequisites

Usage

  1. Put Surface2DBaker script on same GameObject as your NavMeshSurface.
  2. Make sure RenderMesh used for NavMeshBaking has a z-position value between 0 and -1.
  3. Add all components that contain 2D colliders you want to bake to "Objects Containing Obstacles". It is enough to add the root object, the script will automatically also search for colliders in children
  4. Set the NavMesh agent selected in your NavMesh surface to an appropriate size and check if all the baking settings on the Surface2DBaker component are as you want them. Check the tooltip if it's not clear what a setting does.
  5. Press the "Bake 2D" button. Your NavMesh will now be generated.

FAQ

What collider types are being supported?

  • BoxCollider2D
  • CircleCollider2D
  • PolygonCollider2D
  • CompositeCollider2D
  • TilemapCollider2D (For those to work, you have to make them part of a CompositeCollider2D, though!)

Baking takes a really long time, even for a small map, why is that?

Your NavMeshAgent radius is probably way too small. Experiment with the radius until you find a radius that's as big as possible while still giving you accurate results.

The resulting mesh is very inaccurate, why is that?

Your NavMeshAgent radius is probably too big. Experiment with the radius until you find a radius that's as big as possible while still giving you accurate results.

Why didn't you implement a new NavMeshSurface script? Why do we have to use 2 components?

While the NavMeshSurface script and its editor counterpart are open source, they contain a lot of code and they have been changed many times in the past. If I modified this code, I would have to update my project every time Unity changes any of those components. By writing my own component and only using public methods of the NavMeshComponents project, I hope to keep a high level of compatibility with future versions and the need for changes on my side to a minimum.

Known Bugs and Limitations

  • If you are using this tool with tile maps and have non standard colliders and a comlpex setup, you might run into some errors that unfortunately haven't been solved yet and likely never will be, see here. In that case I would recommend you use NavMeshPlus, which was explicitly made to work with Unity tilemaps and won't run into this problem.
  • When using rotated colliders that have parent objects which are scaled, you can run into problems if those parent objects aren't scaled uniformly (every axis being scaled by the same amount). These can cause the cut out shapes on the NavMesh to not have the same shape as the original collider/obstacles and is caused by skewing. For some more explanation about skewing, see here, here and here. Since this problem shouldn't happen in too many cases to begin with, it's easy to work around the problem and also because it would be quite an effort to solve this, I'm currently not planning on implementing any solutions to this.

Compatibility

Current version tested with:

  • Unity 2019.1.0f2
  • Unity NavMeshComponents 2018.3.0f2

3rd party components provided with project

Major Updates

  • April 22, 2019: Added support for scaling and rotation, added support for CircleCollider2D offsets
  • April 20, 2019: Added support for clockwise oriented polygons

navmeshsurface2dbaker's People

Contributors

sharlatany avatar sukender 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

navmeshsurface2dbaker's Issues

Doesn't support rotated colliders

This tools helps a ton. Thank you! It didn't take much rewriting to get it running on Unity 2017.4 LTS (hardest part was figuring out the older way of baking).

Anyhow, first thing I noticed is that it doesn't observe the rotation value of the colliders (at least, not in my version, and I haven't checked the code to see if it should be there). I don't need this at the moment so just noting that it would be nice to have. CapsuleCollider2D might also be nice to have but I go back and forth as to whether or not I might ever use it for walls.

Complex polygon support, thankfully, works wonderfully! That's something that Navigation2D can't seem to do. I'm not even sure A* Pathfinding Project Pro can do it properly.

Navmesh Agent rotation

The navmeshagent ends up rotated -90 degrees. Is there any way to correct this? I'm rotating a child object +90 deg to correct it for now.

Many thanks for your awesome work on this btw

Possible to invert?

Is it possible to invert the generator so the collider is the walkable area?

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.