Hello!
I’m trying to make a new set of animated doors However, I first tried this with a constaint and by setting it to servo. It had wayy to much issues so I then decided to use tweening.
Currently, this is the result:
https://gyazo.com/bc84d505e5a8219248f97ae054ff42b1
My door setup:
Here you can see the closed doors, and the opened doors for refference. Each door consists of one union. They are set to be cancollide false and transparent.
The objects:
My code:
local TweenService = game:GetService("TweenService")
script.Parent:WaitForChild("Open").Changed:Connect(function()
if script.Parent.Open.Value then
-- left door open tween
local part = script.Parent:WaitForChild("lDeur")
local goal = {}
goal.Orientation = script.Parent.lDeurOpen.Orientation
goal.Position = script.Parent.lDeurOpen.Position
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In
)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
-- right door open tween
part = script.Parent:WaitForChild("rDeur")
goal = {}
goal.Orientation = script.Parent.rDeurOpen.Orientation
goal.Position = script.Parent.rDeurOpen.Position
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In
)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
else
-- left door open tween
local part = script.Parent:WaitForChild("lDeur")
local goal = {}
goal.Orientation = script.Parent.lDeurGesloten.Orientation
goal.Position = script.Parent.lDeurGesloten.Position
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out
)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
-- right door open tween
part = script.Parent:WaitForChild("rDeur")
goal = {}
goal.Orientation = script.Parent.rDeurGesloten.Orientation
goal.Position = script.Parent.rDeurGesloten.Position
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out
)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
end
end)
What I have tried so far:
- Moving the door opening position
- Nothing much more, I’m new to tweening.
Is there a way that I can set for example a “middle position” so it MUST go through there? Would the only way to do this be to actually add one and make two tweens for one animation?
Thanks in advance!