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

How do I animate a door opening?

Asked by
shackfu 14
5 years ago
Edited 5 years ago

I tried using Motor6Ds to make an animation for it but when i use the animation editor, it looks really weird. All i want it to do is rotate 45 degrees. What is the best way for me to do this? Edit: and i don't just want it to teleport to the position, I want it to move towards it.

0
Is your "door" a model or a part? SerpentineKing 3885 — 5y
0
it's a model of course shackfu 14 — 5y
0
CFrame DeceptiveCaster 3761 — 5y
0
Cframe HORROR6060 0 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Using CFrame, you can rotate an object...

local Part = workspace:WaitForChild("Part") -- to account for latency
local Rad = math.rad

local function RotatePart(Object)
    Object.CFrame = Object.CFrame*CFrame.Angles(Rad(5),Rad(5),Rad(5))
end

RotatePart(Part)

You can convert degrees to radians cleanly using 'math.rad()' ... or:

local radians = degrees * math.pi / 180

(:Lerp())

for i = 0, 1, .1 do
Object.CFrame = Object.CFrame:lerp(Object.CFrame * CFrame.Angles(0,0,Rad(45)), i)
end
0
I don't want the door to just teleport to the position, I want it to smoothly move to it. shackfu 14 — 5y
0
Teleport to a position? wdym? You should use the :Lerp() method, i'll include it in my answer SaltyPotter 362 — 5y
Ad
Log in to vote
0
Answered by
shackfu 14
5 years ago
Edited 5 years ago

I figured out myself that if I put little "hinges" on the corner of the door I can make the door be animated to move around the corner in a more realistic way.

Answer this question