Tweening models

Hello!

I’m trying to make a new set of animated doors :slight_smile: 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. :slight_smile:
image

The objects:
image

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! :slight_smile:

4 Likes

I think if you avoid setting the position and just apply a rotation it would work a lot less glitchy. Why do you need to change position, anyways?

Because, when I change the rotation only, it creates this result:
image

Make the hinge of the door the primarypart and tween around that part for the door, a similar post asking the same question:

Something that might help:

3 Likes

Thanks! I’ll try this. Using a “betweenpart” didn’t work either :joy:
https://gyazo.com/49f5b4f2c50dabe11ef26766b7def747

Of course it doesn’t work - you are changing the position… If you tween both at the same time this is expected behaviour. But yeah try @3rdhoan123’s method to set the hinge as the primary part. That way you don’t need to worry about the position if it is rotating weird

1 Like

YES! That made it work. :slight_smile: Thanks a lot for the video!!
https://gyazo.com/7eae7ad1285a66b2c030e3178c22fa96