Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I script a smooth walking animation?

Asked by 7 years ago

Hello, I am trying to make my zombie walking animation and I am stuck on how to rotate it smoothly. I don't know a lot of math because I'm just going into high school. Here is what I was thinking about doing.

local zombie = script.Parent
local leftArm = zombie:WaitForChild("Left Arm")
local rightArm = zombie:WaitForChild("Right Arm")
local leftLeg = zombie:WaitForChild("Left Leg")
local rightLeg = zombie:WaitForChild("Right Leg")

local function Animate()
    for i = 1, 45 do
        leftArm.CFrame = leftArm.CFrame * CFrame.Angles(math.cos(math.rad(i)), 0, 0)
    end
end

Animate()

I want to know how to do something like this smoothly and not in an instant. I have tried adjusting the step in the forloop but that didn't work. So can someone tell me how I could create a cool looking animation.

1 answer

Log in to vote
0
Answered by 7 years ago

Of course, you could do it like you are doing, adjusting the angles of parts manually, but there is a MUCH EASIER way to do it.

http://wiki.roblox.com/index.php?title=Animations

Roblox has it's own animation plugin for easy animation creation.

So, I'm assuming you made your zombie with a humanoid.

What you could do is, using the running property of humanoids. You can make an event that plays the animation why the zombie is moving.

http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Running

EXAMPLE:

local animController = Instance.new("AnimationController")
local animTrack = animController:LoadAnimation(-- path to animation here)

local Zombie= -- The zombie

Zombie.Running:connect(function(speed)
if speed>0 then
animTrack:Play()
else
animTrack:Stop()
end
end)
0
thanks Troloolooolooll 9 — 7y
Ad

Answer this question