Yo! u probably have already seem me in this forum
Basically, from a old post i made somebody told me to use pathfinding to detect players and magnitude to do what i want when its close to the player
But i find it really hard working with pathfinding and all tutorials i see i cant understand
Could anyone explain better for me how do i use pathfinding and magnitude to make the AI functions?
(The AI magnitude functions are the rake functions,so like the rake get faster when its close to the player and screen flashing, and a song when rake is close)
Hope i could explain well my problems
it would be cool if anyone could explain better to me
local PathfindingService = game:GetService("PathfindingService") -- Getting the service
local path = PathfindingService:CreatePath() -- Creating a new path
path:ComputeAsync(pos1, pos2) -- Computing the waypoints
local waypoints = path:GetWaypoints() -- Get all the waypoints
That is in essence how pathfinding works, and if you wanted to move a character then you can loop through the waypoints table and move the character to each waypoint
for _, waypoint in pairs(waypoints) do
Character.Humanoid:MoveTo(waypoint.Position) -- Moves the character to the waypoint
Character.Humanoid.MoveToFinished:Wait() -- Waits until the character is done moving so that it doesn't try to move to the next waypoint before it's finished with its current one.
end