Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

PathfindingService Navmesh Not Updating On Runtime?

Asked by 7 years ago
Edited 7 years ago

On the wiki reference for PathfindingService (API:Class/PathfindingService), it states that "PathfindingService generates a navigation mesh over all of the parts in the place while a game is running" and "If the geometry of the place changes, for example if a part moves or is created, then the navigation mesh will be recalculated." It also states this on the DevForum post regarding the release of the new pathfinding system: "Dynamic Navigation Mesh generation: The navmesh will automatically regenerate when obstacles move around the world." (Introducing: Roblox Pathfinding)

However, my navmesh is not updating while running the game with the studio "run" button, nor does it seem to update while playing through the normal client.

I have a script that spawns a new brick a second after the game starts running and resizes a premade brick in the Y axis, to make what was previously a jumpable surface too high to be jumped upon. The navmesh does not take these changes into account. (Screenshot)

Why isn't the navmesh updating in real time, even though it is supposed to? Thanks.

Edit: After some more playing around, I found out that the navmesh only updates with a new call of FindPathAsync of PathfindingService. CheckOcclusionAsync is supposed to check if a path is made invalid, but my implementation doesn't seem to work. Here is my script for my pathfinding:

01local pathfinding = game:GetService("PathfindingService")
02 
03local startBrick = workspace.NPC.Torso
04local endBrick = workspace.GoBrick
05local reachedEnd = false
06 
07function getPath()
08    path = pathfinding:FindPathAsync(startBrick.Position, endBrick.Position)
09    waypoints = path:GetWaypoints()
10end
11 
12 
13--Works fine, not related to this problem
14function drawWaypoints()
15    --Shows path visually
View all 60 lines...

So it seems that CheckOcclusionAsync is never making blocked ~= -1. The wiki page isn't very helpful for the function. It wants an int start as the parameter, but what exactly is that int? I've been passing it the index of my current waypoint, but that seems to be the wrong assumption.

Answer this question