Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CacheSources2D doesn't cache correctly #216

Open
JevinLevin opened this issue Oct 23, 2024 · 3 comments
Open

CacheSources2D doesn't cache correctly #216

JevinLevin opened this issue Oct 23, 2024 · 3 comments

Comments

@JevinLevin
Copy link

JevinLevin commented Oct 23, 2024

May be user error, but I can't seem to fix despite copying the example scene exactly.

It collects the sources but for some reason does not cache them, despite them containing nav modifiers. This then stops me from being able to update the sources when they change position or are removed
image

I use the following code to create and update the navmesh

    private IEnumerator StartNavMesh()
    {
        if (navMeshSurface.useGeometry == NavMeshCollectGeometry.PhysicsColliders)
        {
            yield return new WaitForFixedUpdate();
        }
        navMeshSurface.BuildNavMesh();
        yield return null;
    }

    public void UpdateNavMesh(GameObject source)
    {
        cacheSources2D.RemoveSource(source);
        
        if (cacheSources2D.IsDirty)
        {
            cacheSources2D.UpdateNavMesh();
        }
    }

The surface is a tilemap with a tilemap modifier, and it uses 3D objects with modifiers to mark the non-walkable areas

@JevinLevin
Copy link
Author

JevinLevin commented Oct 23, 2024

I found the cause, the NavMeshBuilder2d class only contains the CollectSources functions for SpriteRenderer, Collider2D and tilemap, whereas I was using regular Collider for 3D objects.

I am unsure if this is an oversight, or a misuse of the components. The idea is to generate the nav mesh using the tilemap, and then create 3D objects with modifiers that are placed on the tilemap to generate the non-walkable areas. I added an overload for regular Collider component which fits my usecase for now.

@h8man
Copy link
Owner

h8man commented Oct 23, 2024

Hi, tools has focus on 2d, never thought it will be used with 3d components. Can you make a PullRequest? I'll looks and try to add 3d cache support if its fits design.

@JevinLevin
Copy link
Author

Sadly the solution I'd come up with didn't actually end up working and I had to ditch the idea. But I think it's definitely feasible to add if you do wanna have a look in the future 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants