How to ignore/go through 2D Collision during runtime?

Hello everyone.

I have a 2D top-down game and I’m basically using additive scenes, like whenever player goes to another scene, the current scenes gets unloaded and target scene is loaded, and then the whole scene is scanned again, however there’s a persistent scene which is always loaded, so NPCs are there, and if they’re not in loaded scene, their sprite is set inactive.

Now the question is, since the whole scene is scanned again, previous scene’s collision informations are no longer valid and current scene’s collision informations are applied, this causes a little problems for my NPCs who are still supposed to be roaming in ‘unloaded scene’.

So I am looking for a way to make my invisible NPCs pathfinding somehow ignore the collisions when they are not visible in scene (not active) but still roaming around, so that active scene’s collision infos are not preventing them from walking freely.

To summarize, how can I make my NPC pathfinding to create path through collisions with Obstacle Layer Mask with 2D Physics, so that NPC can go through collisions?

Hi

So do I understand you correctly that these agents are still on the graph, but there are no colliders there?
In that case I think the default configuration for the graph should make that whole surface walkable and it should work just like you want it. What are you seeing?

Actually Aron, what I intended was to have two seperate agents in the same grid and one of them will have its seeker’s pathfinding not get affected by certain collisions, let’s say, it’s seeker’s obstacle layer is ExteriorWall, when the agent goes into an apartment from the street, Obstacle Layer for that agent will change to InteriorWall, so that ExteriorWall layer won’t affect his seeker’s pathfinding.
However, for some reasons I realized this is not the best approach even if it was possible to succeed it, so I eliminated that option. :slight_smile:

Lastly I was wondering if it is possible create more than 32 Grid Graphs, as it’s created with bitmask, I understand it is limited to 32, correct? That means I cannot use more than 32? Is there a way to have more than 32 Grid Graphs that each of them will have unique data?

It sounds like you want to have a look at https://arongranberg.com/astar/docs/tags.php

Also, the max number of graphs is actually 255 internally, however many bitmasks can (as you say) not represent more than 32 graphs.

Oh thank you, I’ll definitely study the link you sent to have a better grasp of it.

And sorry for upcoming noobish question, but I want to make sure that I understand all correctly :slight_smile:

So I am able to create more than 32 graphs, however; on my agent’s seeker script on unity editor, I am able to see only 32 graphs. And I use "GraphMask.FromGraphName(“GraphName”); to access Graphs, I can’t access to graphs that come after 32nd graph? Is there a way to access to 255 of them with this FromGraphName method or by something else, in case I’d like to use more than 32?

Hi

Unfortunately not. The graph masks only support 32 graphs.