• Getting whether there's a valid path between entity and point?
    0 replies, posted
Using navmeshes, would it be possible to get whether there'd be a valid path between any given entity (even non-nextbots) and position? The plan is to use this to determine whether a spawnpoint for the nextbots would be valid or not by using the spawnpoint entity as the start so that the bots only spawn where they can get to players. I have already tried fiddling with it by using path:Compute() and a custom function, but it keeps returning failed and doesn't print the messages inside the function. [lua]function HasValidPath(start, target) print("Beginning") local path = Path("Chase") path:SetMinLookAheadDistance( 300 ) path:SetGoalTolerance( 50 ) print(path) //Compute a path - return true if it exists path:Compute( start, target, function( area, fromArea, ladder, elevator, length ) print("Computing ...") if ( !IsValid( fromArea ) ) then print("In same area") return true else if ( !startent.loco:IsAreaTraversable( area ) ) then //Our locomotor says we can't move here print("Not right") return false end //Check height change local deltaZ = fromArea:ComputeAdjacentConnectionHeightChange( area ) if ( deltaZ >= self.loco:GetStepHeight() ) then if ( deltaZ >= self.loco:GetMaxJumpHeight() ) then //Too high to reach print("Too high") return false end end print("Possible!") return true end end) print(path) return path:IsValid() end[/lua] The pathfinding function used here is the same as the one used on the nextbots spawning, except just returning true or false and not calculating the cost. I have tried returning -1 and 0 instead but both times path:IsValid() is false. Would this type of thing be possible without the use of a nextbot?
Sorry, you need to Log In to post a reply to this thread.