I recently revamped my movement system so it can play animations and do some other cool stuff, to do that i just covered the entire enemy with a part named hitbox and i anchored it and i welded the humanoidrootpart to it, and it works, i made a tween to rotate it to the next node, but the tween is not playing.
code:
local enemies = game.ServerStorage.Enemies
local ts = game:GetService("TweenService")
local nodes = game.Workspace.Nodes
local node = nodes:GetChildren()[1]
function spawnEnemy(typeOf)
local zom = typeOf:Clone()
zom.Parent = workspace
moveEnemy(zom)
return zom
end
function moveEnemy(Enemy)
for i = 1, #nodes:GetDescendants() do
local dist = (Enemy.HumanoidRootPart.CFrame.Position - node.CFrame.Position).Magnitude
local speed = Enemy.Configuration.Speed.Value
local Time = dist/speed
print("dist:"..dist, " Speed:"..speed, " Time:"..Time)
local info = TweenInfo.new(Time, Enum.EasingStyle.Linear)
local tween = ts:Create(Enemy.Hitbox, info, {CFrame = node.CFrame+Vector3.new(0,Enemy.Hitbox.Size.Y/2-node.Size.Y/2, 0)})
tween:Play()
tween.Completed:Wait()
local dec = node:GetChildren()
node = dec[1]
-- Rotating
local info = TweenInfo.new(0.3)
local tween2 = ts:Create(Enemy.Hitbox, info, {
CFrame = CFrame.new(Enemy.Hitbox.Position, node.Position)
})
tween2:Play()
end
end
print(enemies:GetChildren())
spawnEnemy(enemies.Normal)