Hi, I am trying to figure out how to move a humanoid with just the Humanoid:Move method. I don't want to use MoveTo cause it is pretty clunky at times. This is what I have so far, and it is not working, the humanoid just goes in one direction. Imagine that waypoints is just a table of Vector3's
local RS = game:GetService("ReplicatedStorage")
local PathFinding = require(RS:WaitForChild("PathFinding"))
local dummy = script.Parent
local endPos = workspace:WaitForChild("EndPos")
local humanoid = dummy.Humanoid
local endPosition = endPos.Position
local pathfinding = PathFinding.new(true)
local waypoints = pathfinding:CreatePath(dummy, dummy.PrimaryPart.Position, endPosition)
if (waypoints == nil) then
print("ok")
waypoints = {}
end
local index = 1
local current = dummy.PrimaryPart.Position * Vector3.new(1,0,1)
local endLoc = waypoints[index].pos * Vector3.new(1,0,1)
print(endLoc)
local direction = (endLoc - current).Unit
while index <= #waypoints do
task.wait(.5)
humanoid:Move(direction)
if (dummy.PrimaryPart.Position - endLoc).Magnitude <= 1 then
current = waypoints[index].pos * Vector3.new(1,0,1)
index += 1
endLoc = waypoints[index].pos * Vector3.new(1,0,1)
direction = (endLoc - current).Unit
else
print((dummy.PrimaryPart.Position - endLoc).Magnitude)
end
end