I’m using TweenService to move a part down a path created by PathfindingService. Everything works correctly except one problem: The part does not face the correct direction. PathfindingService doesn’t provide any kind of direction. What should I do in order to get it to face the direction it’s going?
In the gif above, the part doesn’t face the forward direction, rather the direction in which it was instantiated in.
local path = pfs:CreatePath()
path:ComputeAsync(initialStartingPosition,start)
for i,v in pairs(path:GetWaypoints()) do
local twn = TweenService:Create(g,TweenInfo.new(0.5,Enum.EasingStyle.Linear),{Position=v.Position})
twn:Play()
twn.Completed:Wait()
end
Note: I’m not looking for the part to face the player. I’m looking for it to face the direction it’s moving.
I’m aware of that. The problem (as stated above) is that PathfindingService doesn’t provide a directional vector I can use to face the part toward the moving direction, which is why I’m asking how I should make the part face the direction it’s moving.
Worked, however occasionally the part will look directly down. Wonder why that could be?
Code:
for i,v in pairs(path:GetWaypoints()) do
local nex = path:GetWaypoints()[i+1]
if nex then nex = nex.Position+Vector3.new(0,2,0) else nex = v.Position + Vector3.new(1,2,0) end
local twn = game:GetService("TweenService"):Create(g,TweenInfo.new(0.5,Enum.EasingStyle.Linear),{CFrame=CFrame.new(v.Position+Vector3.new(0,2,0),nex)})
twn:Play()
twn.Completed:Wait()
end
This is the first time I was able to reproduce it with every object, previously only one would go down and up while the rest would go straight normally.
Edit: Only one did it previously, but since I moved the starting point all five started to do it.