Pathfinding NPC [BUG]
Hey there developers! I’m at the moment working on an AI system for my NPC Monster but I’m having some problems! whenever my monster is turning from its destination parts it begins rotating from side to side and I really don’t understand why. I’ve tried fixing this for hours but I ain’t getting anywhere. Let me know if there already is a post about the same thing please let me know cause I can’t find any posts about this bug myself!
SCRIPT INSIDE OF THE MOSTER:
local Wendigo = script.Parent
local humanoid = Wendigo.Humanoid
local PathfindingService = game:GetService("PathfindingService")
local function getPath(destination)
local pathParams = {
["AgentHeight"] = 10,
["AgentRadius"] = 2,
["AgentCanJump"] = false
}
local path = PathfindingService:CreatePath(pathParams)
path:ComputeAsync(Wendigo.HumanoidRootPart.Position, destination.Position)
return path
end
local function WalkTo(destination)
local path = getPath(destination)
for index, waypoint in pairs(path:GetWaypoints()) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
end
while true do
WalkTo(workspace.destination)
WalkTo(workspace.destination2)
WalkTo(workspace.destination3)
WalkTo(workspace.destination4)
WalkTo(workspace.destination5)
WalkTo(workspace.destination6)
WalkTo(workspace.destination7)
WalkTo(workspace.destination8)
end
VIDEO OF BUG:
Thanks for reading I hope you can help me solve this!
`