i am making a small tower defense game, and i just finished the zombie movement, it works perfectly fine, but there is one thing that triggers me, the zombie goes inside the path, it is very subtle, but then you when it reaches it’s current node, it just slightly goes up, unfortunately, i cannot send a vid but i can show you a model: path thingy - Roblox
script:
local root = script.Parent.HumanoidRootPart
local path = game.Workspace.path
local TweenService = game:GetService("TweenService")
for i = 1, #path:GetChildren() do
local node = path:FindFirstChild('node'..i)
print(node.Name, i)
local dist = (root.CFrame.Position - node.CFrame.Position).magnitude
local speed = 3
local Time = dist/speed
local info = TweenInfo.new(Time, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local tween = TweenService:Create(root, info, {
CFrame = CFrame.new(node.CFrame.Position.X, node.CFrame.Position.Y+2, node.CFrame.Position.Z) * CFrame.fromEulerAnglesXYZ(root.CFrame:ToEulerAnglesXYZ())
})
tween:Play()
tween.Completed:Wait()
end
The problem is on CFrame = CFrame.new(node.CFrame.Position.X, node.CFrame.Position.Y+2, node.CFrame.Position.Z) * CFrame.fromEulerAnglesXYZ(root.CFrame:ToEulerAnglesXYZ()).
local root = script.Parent.HumanoidRootPart
local path = game.Workspace.path
local TweenService = game:GetService("TweenService")
for i = 1, #path:GetChildren() do
local node = path:FindFirstChild('node'..i)
print(node.Name, i)
local dist = (root.CFrame.Position - node.CFrame.Position).magnitude
local speed = 3
local Time = dist/speed
local info = TweenInfo.new(Time, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local tween = TweenService:Create(root, info, {
CFrame = CFrame.new(node.CFrame.Position.X, root.Position.Y, node.CFrame.Position.Z) * CFrame.fromEulerAnglesXYZ(root.CFrame:ToEulerAnglesXYZ())
})
tween:Play()
tween.Completed:Wait()
end