0

# Pathfinding wants to go up first?

Hi I'm new to Pathfinding and I just learned about it in a video by TheDevKing. I followed his tutorial which did worked but I needed to create a few lines of code myself because he is using a character and I'm using a object. I used TweenService instead of MoveTo which would suit my problewm. It works now but there is a slight bug where when it starts it goes up then it comes back down and proceeds with the normal path. I have no idea why this is happening and cant find anything on it. Help. Thanks in advance!

Please keep in mind that it is not enclosed in anything and is a straight shot to the end point with nothing in its path.

Code:

local PathfindingService = game:GetService("PathfindingService")
local TweenService = game:GetService("TweenService")

local chase = script.Parent
local human = script.Parent:WaitForChild("Humanoid")

local tweeningInfo = TweenInfo.new(
0.2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut
)

local path = PathfindingService:CreatePath()
path:ComputeAsync(chase.Position, game.Workspace.End.Position)
local waypoints = path:GetWaypoints()

wait(2)
for i, waypoint in pairs(waypoints) do
local part = Instance.new("Part", game.Workspace)
part.Shape = "Ball"
part.Material = "Neon"
part.Size = Vector3.new(0.6, 0.6, 0.6)
part.Position = waypoint.Position + Vector3.new(0, 2, 0)
part.Anchored = true
part.CanCollide = false

local position = waypoint.Position
local tweenProperties = {Position = position + Vector3.new(0,5,0)}
local tween = TweenService:Create(chase, tweeningInfo, tweenProperties)
tween:Play()
tween.Completed:Wait(2)
end

0
Pathfinding Service tries to find the quickest way to get to the waypoint, Since you are using tween service, It has no gravity limitation, So in that case he just fly's all the way up to the endPoint! MattVSNNL 378 — 1mo