Currently making NPCs for my game, but they walk on the lava that kills them when the player can technically be reached faster this way.
Is it possible to blacklist certain parts from the PathfindingService calculation in order to prevent such a thing from happening?
I imagined I could simply tick off collisions from lava, but that would mean anyone could kill a boss by simply pushing them in it and they couldn’t prevent their fall.
You can set if statement to lava brick do don’t kill humanoid when it’s parent is boss
they’d still die because they would go right through it
Your best bet is probably to do some trickery where you make some invisible parts where the lava is that are made collidable only in the instant when a path is being computed for agents that shouldn’t be able to walk across lava, and made non-collidable again immediately after. This should be possible without race conditions if you use CreatePath, but I haven’t tried it so I don’t know if it actually works.
Another workaround is to keep a separate level that is identical to the “real” level in terms of parts that are relevant for pathfinding, but is really far off in the distance so it can’t be seen or touched or ever overlap with the real level. That way you can set it up exactly how you want it for pathfinding without affecting other stuff. If you need different agents to pathfind differently, you must either change the level as I described in the first workaround, or keep several different “pathfinding levels”.
uhhh you mean ticking off CanCollide during a calculation and back on when it’s not the case, right?
Yeah, or ticking it on to prevent movement through it.
Like in this illustration, you make the invisible pink box cancollide so nothing can walk on top of the lava, and any generated paths go around the lava.
Instead of blacklisting parts, wouldn’t it be easier just to whitelist them?
oh i see
that’s a smart way of working around that
thanks
ermm yeah i gues
well blacklisting or whitelisting, it depends on whether or not you thought that BL’d parts are acceptable or not
Next week Polaris-Nav will move into testing. It supports selecting the parts to create a nav mesh and editing the mesh after creation. You won’t have to resorting to hacky solutions anymore: Polaris-Nav