Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I animate a door opening?

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.

4 comments

0

Is your "door" a model or a part?

0

it's a model of course

0

CFrame

0

Cframe

2 answers

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

2 comments

0

I don't want the door to just teleport to the position, I want it to smoothly move to it.

0

Teleport to a position? wdym? You should use the :Lerp() method, i'll include it in my answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.