The NPC functions properly if I don’t run ComputeAsync in a loop of sort.
When I put it in a task.wait loop with any delay the NPC doesn’t go to the next waypoint if a steep slope or truss is the path to get there, it just stops infront of the slope or truss.
No matter what the loop is when I run ComputeAsync inside the loop this bug occurs.
I made an NPC that constantly chases the player smoothly so I want a task.wait() loop, like no wait time inside of the parenthesis.
Switching the agent parameters doesn’t work, and yes I have AgentCanClimb on. This happens with every single dummy or rig I try, so it is without a doubt not the rig.
Basically, changing hipheight, parameters, rig, loop has all not worked. I highly suspect this is a problem with running it too many times but if I don’t it will walk via outdated waypoint which I highly don’t want. I’ve seen other games achieve the NPC I want like, Tower Battles: Battlefront, Defend the Statue or Zombie defense 4.
while task.wait() do
Path:ComputeAsync(NPC.PrimaryPart.Position, workspace.SpawnLocation.Position)
local Waypoints = Path:GetWaypoints()
local nextWaypoint
if Path.Status == Enum.PathStatus.Success then
for i, Waypoint in Waypoints do
if VisualSetting == true then
local Visual = Instance.new("Part")
Visual.Size = Vector3.new(.5, .5, .5)
Visual.Position = Waypoint.Position
Visual.Parent = workspace
Visual.Material = Enum.Material.Neon
Visual.Shape = "Ball"
Visual.Anchored = true
Visual.Color = Color3.fromRGB(255, 255, 255)
Visual.CanCollide = false
Visual.CanQuery = false
Visual.CanTouch = false
end
nextWaypoint = 2
NPChum:MoveTo(Waypoints[nextWaypoint].Position)
end
end
end
The code exists within a function that run once, its destination is a part that doesn’t move but in the very near future I will make it target the closest player.
I’d highly appreciate and be grateful an actual response on how to fix this.
Hello,
I tested your situation on my player targeting zombie model and I had the same issue so I tried using humanoid:Move(directionToEnemy) when it just cant generate any paths but see the target it trys moving into it and kinda got it working.You may want to check by raycasting if you want it more professional.
also I used clamping when trying to achive waypoints (prefering 3rd index)
local waypoint = waypoints[math.clamp(3,2,#waypoints)]
The path generates, but the NPC just doesn’t walk to the next point if a ladder or high slope is in the way. Why would you use Move and not MoveTo? Also using the third index just makes the NPC less smart, and it sometimes just doesn’t complete obstacles when using third index point. I know as I have already tried using this solution, (it didn’t work).
So I tried second index and it just stops at steep slopes but on third index it keeps jumping and following Im not sure what to chose but I havent got it working properly on obstacles.
might be a stupid take but i dont think path finding is working at all for new places - for some reason it works for other people idk why. i had the same issue as u and all i was getting is my print(“No path!”)
Hm, I will be completely honest, I doubt that. Pathfinding free models work, I’ve recently tested if this was true. It’s not, so perhaps you can check if your script simply has a bug as Roblox Studio doesn’t.
well first of all if there were multiple npcs the raycast would just be blocked by them plus if theres a path on the end of the stairs and i traverse it enough the raycast wouldnt hit at times as the stairs would be blocked
if i knew how to fix the multiple npcs = raycast blocked thing i woulda never made this forum cuz i woulda used that instead (cant bother using grammar im getting tired of this problem, i wanna solve it so bad but i cant)
Try working with Humaniod MaxSlopeAngle.
And like BadDad2004 said … AgentCanClimb = true
This is the best resource for this I’ve seen yet. There is an example of just what you’re doing. Character Pathfinding
i found some posts saying that when a part is too large its hard for the npc to read. Change the humanoid hipheight on the npc or make the part smaller - as well as setting the waypoint to a high position for some reason might be something.