Gyazo Ex
Long story short I was trying to make a path finding demon for a sword, I am trying to learn pathfinding as I rarely work with AI… I got the basic format and I think got it working, the only problem is Humanoid:MoveTo would actually function unless acted upon, by being touched, or jumping… Why is this so??? The code does not error, and does not function, I may have to make a different ultimate…
Code below:
pathToTarget = function(character, targPosition, ignoreTB, objectTarg)
local ray = Ray.new(character.HumanoidRootPart.CFrame.p, (targPosition- character.HumanoidRootPart.CFrame.p).unit * 100)
local part, position = workspace:FindPartOnRay(ray, char, false, true)
if part.Parent.Name == objectTarg.Name then
--We can directly walk to the target
character.Humanoid:MoveTo(targPosition)
character.Humanoid.MoveToFinished:Wait()
else
--We must pathfind
local PathfindingService = game:GetService("PathfindingService")
local path = PathfindingService:ComputeRawPathAsync(character.LowerTorso.Position, targPosition, 100)
local points = path:GetPointCoordinates()
wait(1)
for x, point in pairs(points) do
character.Humanoid:MoveTo(point)-------------------------------------------------------
local distance
repeat
distance = (point - player.Character.LowerTorso.Position).magnitude
character.Humanoid:MoveTo(character.Head.Position)
character.Humanoid:MoveTo(point)
wait()
until distance < 4
end
end
end