Giter VIP home page Giter VIP logo

Comments (4)

h8man avatar h8man commented on May 18, 2024

Hi,

I see dotted line, and bake setting Default Area - Walkable.
So first NavMeshPlus creates huge box area as walkable, and than carves out unwalkable regions.
I assume that you sprite shape are not complete squares and have some gaps, and those gaps are not carved out.

You can override tile shape by "Use Mesh Prefab", as you do.
Or, if your world is in square tiles, enable "Override by Grid".
Or, better use this scenario https://github.com/h8man/NavMeshPlus/wiki/HOW-TO#baking-a-maze

Also, enable compress bounds, it will increase bake time, but also will delete excessive tiles.

from navmeshplus.

subGlitch avatar subGlitch commented on May 18, 2024

I assume that you sprite shape are not complete squares and have some gaps, and those gas are not carved out.

But does it matter? Because I use ColliderType.Grid, not ColliderType.Sprite.

Oh! I've just managed to fix the problem! See my fix in the code below. This is part of NavMeshBuilder2d.CollectTileSources() method. I don't understand why it fixed the problem. It was just a lucky guess. I wonder what was the issue...

else //default to box
{
    var boxsrc = new NavMeshBuildSource();
    boxsrc.transform = Matrix4x4.TRS(Vector3.Scale(tilemap.GetCellCenterWorld(vec3int), builder.overrideVector) - tilemap.layoutGrid.cellGap, tilemap.transform.rotation, tilemap.transform.lossyScale) * tilemap.orientationMatrix * tilemap.GetTransformMatrix(vec3int);
    boxsrc.shape = NavMeshBuildSourceShape.Box;
    // boxsrc.size = size;                          // problem: NavMesh artefacts =(
    boxsrc.size = new Vector3( 1, 1, 0 );           // All good!
    boxsrc.area = area;
    sources.Add(boxsrc);
}

from navmeshplus.

h8man avatar h8man commented on May 18, 2024

Hi,

Yes, it does matter if you bake Geometry https://github.com/h8man/NavMeshPlus/wiki/HOW-TO#used-geometry
NavMeshPlus does not tolerate tilemaps "ColliderType".
Unity have public API to get mesh form sprite, or mesh from collider, but not mesh from grid cell, or mesh from sprite physics shape. And we need that mesh.

As for code above, I assume there is a bug. If both "Override Grid" and "Use Mesh Prefab" are used, than "size" is overwritten and does not correspond to grid's cell size.
var size = new Vector3(tilemap.layoutGrid.cellSize.x, tilemap.layoutGrid.cellSize.y, 0);
and
if (builder.useMeshPrefab != null) { ... size = builder.useMeshPrefab.transform.localScale;

from navmeshplus.

subGlitch avatar subGlitch commented on May 18, 2024

var size = new Vector3(tilemap.layoutGrid.cellSize.x, tilemap.layoutGrid.cellSize.y, 0);

Yep, this works! Thanks!

from navmeshplus.

Related Issues (20)

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.