So I’m encountering this problem where bigger zombies in my TD game are sinking inside the path, whereas on the other hand, smaller zombies walk on the path perfectly fine.
How can I make the script adjust the Y-axis so the bigger zombie will walk on the path perfectly?
Code:
function zomb.Move(Zombie)
local speed = Zombie.cfg.Speed.Value * 100
local pathway = workspace.pathway
local BezierPath = require(workspace.BezierPath)
local waypoints = {pathway.Spawn.Position}
for i = 1, #pathway:GetChildren() - 2 do
table.insert(waypoints, pathway[i].Position)
end
table.insert(waypoints, pathway.Exit.Position)
local NewPath = BezierPath.new(waypoints,4)
local HumanoidRootPart = Zombie.HumanoidRootPart
for t = 0,1,1/speed do
HumanoidRootPart.CFrame = NewPath:CalculateUniformCFrame(t)
task.wait(0.01)
end
Zombie:Destroy()
end
Do you have access to positions from the module? Does the module only calculate it’s path with x and z positions?
I have no idea on how the module works
Would this work?
for t = 0,1,1/speed do
HumanoidRootPart.CFrame = NewPath:CalculateUniformCFrame(t) + Vector3.new(0, 1, 0)
task.wait(0.01)
end
This would work, but now, smaller zombies will float above the path. Is there anyway I can detect if the zombie is sinking and how much it is sinking to make them walk on the path normally
‘Y’ not? lol.
I don’t mean remove it entirely.
The Humanoid.HipHeight should take care of the Y axis. If so you could even make paths with hills and valleys.
If not just make the Y value in the script the Y Position of the Humanoid so it stays at the correct height.
Couldn’t you just change the hip height in the zombies humanoids without a script? I had this problem with scaled rigs and I set the humanoid hip heights higher in the rig until the rig did not go under the baseplate.
for t = 0,1,1/speed do
HumanoidRootPart.CFrame = NewPath:CalculateUniformCFrame(t) * CFrame.new(0, HumanoidRootPart.Size.Y * 1.5, 0)
task.wait(0.01)
end