Hey all,
So basically what I am trying to do is make a pathfinding system that will move parts and angle them to the node while moving through the pathfinding sequence. Here is some example code I wrote up:
local pathfinding = game:GetService('PathfindingService')
local tws = game:GetService('TweenService')
local path = pathfinding:CreatePath()
local sp = workspace.StartPart
path:ComputeAsync(sp.Position, workspace.End.Position)
local points = path:GetWaypoints()
for i,v in pairs(points) do --// generate the visual nodes
local r = Instance.new('Part')
r.Shape = 'Ball'
r.Anchored = true
r.BrickColor = BrickColor.Blue()
r.Transparency = 0.5
r.Size = Vector3.new(1,1,1)
r.Position = v.Position
r.Parent = workspace
end
for i, m in pairs(points) do
tws:Create(sp, TweenInfo.new(0.5), {CFrame = CFrame.new(m.Position)}):Play()
wait(0.5)
end
Using this code yields this result:
https://gyazo.com/3ba9cba9e7326692ce6d143c39a3641d
However, what I am trying to achieve is something more along the lines of this:
As you can see, the part is actually facing the node.
Logically, I tried doing this to set the look vector like normal:
CFrame.new(m.Position, m.Position)
But when I do this, the part gets sent to a negative Y coordinate of -340282346638528859811704183484516925440
Does anyone have any advice or ideas?