In this image player, A and B are not in the room and are separated by the middle wall. The script would return a false bool.
Using a raycast method from my research wouldn’t work as it makes 1 direct line. If a wall is between the fastest direct line but there is a hole in the wall somewhere else the raycast wouldn’t detect it.
Using pathfinding also wouldn’t work as it wouldn’t detect small cracks.
If you are able to preprocess the content manually it is usually going to be faster and easier to do that. You could simply define room boundaries with parts and see are both players within the same room that way. If the content is user generated or you don’t want to preprocess it for some other reason I would still recommend pathfinding service as the easiest way to do this. If you need to detect small cracks in the wall, one possible solution would be scaling rooms up to 2x or 3x the size so that these gaps are recognized.
My environment is constantly changing at random meaning it wouldn’t be possible to make pre-made rooms. Testing with the new path-finding function shows that it isn’t really the best at going through hallways. An average user can go through the hallway fine but when put with the path-finding it struggles to go through the hallway.
Maybe you could make a custom pathfinding method that works in a custom grid system? (Doesn’t even need to be custom, could just be using the default 1 stud grid Roblox uses.) This would also mean all of your rooms’ walls would need to be snapped to that grid, but that shouldn’t much of an issue even with randomly generated stuff.
I see I could use that. My big worry here is that I’ll end up using a system that would take up to 2+ to return something back. I am taking this option into consideration tho but gamer’s method is probably the best for right now as Roblox is gonna keep on updating their new pathfinding system later on.
I don’t think it would take that long – computers are surprisingly quick with things. I think if you have, say, a 50x50 room, that’s only 2500 grid pieces you’ll need to go through. However, your room will also have walls, and the pathfinding algorithm isn’t a (simple) bruteforce so you’ll actually be doing a lot less than that.
I also doubt the pathfinding system will be made usable for things like this at any time useful to you