How do I fix this pathfinding issue

Basically, I have a rig that walks around and when he finishes walking he places a can collide true block (but its in a collision group with the rig thats set to false so the block doesnt fall through the floor), But it considers this a blockage and therefore when the script is trying to compute a successful path it takes the non walkable through pieces into play, so if the rig ran into the corner it would be trapped there forever repeatedly calculating a successful path. How do I make it ignore the pieces he places behind?

Any help is appreciated!

Look at the ignoring obstacles section.

I deleted the wrong text if you’re wondering why I have a deleted post directly above this one.

It’s also worth noting if it’s canCollide true purely to keep it from falling through the floor, you should consider anchoring it instead.

Also if it’s only placed for a special effect, you could make it appear on the client which could fix that issue if the ai is calculated on the server.

Either what @tlr22 said, or if you don’t want to have Parts blocking a path you could check to see when the rig is placing the Part if there is something else a few studs away. You could then make it so the Part get placed to always have a path around them?

This will work BUT, the part the rig spawns is unanchored but has can collide so if i want to add a modifier i need an unanchored part that is the same size as the part welded without being broken by positioning (which i just tried all this and the pathfinder still has trouble)

Could you not just put the modifier directly in the part?

I said it wrong, its non can collide in the collision group so the player can touch it and pick it up without physically touching

It says it needs the part to have cancollide false

I wonder if it is saying that because it won’t work on an object that has canCollide false or if it is merely stating that so you remember not to have an invisible block that players will hit extending beyond the door.

I havent really used it before so you should try that approach anyways as the post doesn’t state the exact reason for why.

tldr try it anyways. The documentation doesn’t state that.

image

I have tried adding the modifiers to the parts instead but it still counts them as blockages.

Ahh. Well if the attempt failed it doesn’t work that way probably.

The thing you quoted was from a tutorial though. Not the actual documentation. That’s why there was room for ambiguity.

1 Like

Where can I find the legitimate documentation.

Modifiers in general
https://developer.roblox.com/en-us/api-reference/class/PathfindingModifier

Specifically this property

https://developer.roblox.com/en-us/api-reference/property/PathfindingModifier/PassThrough

All I’m doing is adding a pathfinding modifier to an unanchored can collide part with pass through set to true, but this doesn’t work. How can I fix this?

I’m unsure I haven’t used pathfinding much. I have my own scripts for it that give me far more control.

Do you only have it canCollide true specifically to keep it from falling through the floor? If that’s the case it would be better to raycast it to the floor and anchor it. If there are other reasons for it to be canCollide true then that won’t work though.

No its just can collide true for anything really.

I have 4 potential solutions organized by a combination of ease to implement and practicality.

  1. If the cancollide is really only affecting the players. Have a local script make canCollide true on those blocks so that only players can collide. They would stay cancollide off on the server. The biggest drawback being that if there is another agent on the server, then it also would go through these.

  2. This is a partial fix to the major problem from above, but could be used as it’s own solution. Make it so normally they are canCollide false, just turn them true whenever an agent gets near them. You could also add that pathfinding modifier at that point too or create another way for the creature to go through that block.

  3. Create your own pathfinding script. This can take a ton of work though. The pathfinding algorithm itself shouldn’t be hard to implement the problem is the data you use to pathfind. You have to create it yourself.

  4. Probably the worst idea imo and can certainly beak more than it fixes, but create a duplicate of the map like 1000 studs below it. Then don’t add anything to that second map the agent can go through. Then to pathfind start by doing a -Vector3.new(0, 1000, 0) to the start and goal. Then add Vector3.new(0, 1000, 0) to all nodes and you have yourself a path. I mean it will work and it will work wonderfully, but it’s an entire duplicate map.

edit: you could also try to use pathfinding links instead. Won’t be perfect, but could work.

I fixed the problem in the end anyway with an unknown thing I tried but I have an issue where when I use the pathfinding modifiers to make can collide parts walk through, the path compute still fails. How to fix?

You need to make an AgentParameter note of the modifier, or it won’t work.
image