Tweening an orientation smoothly between Positive and Negative orientations

What do I want to achieve?
I’m trying to tween a part from a high positive Y value to a low negative Y value (example, 130 to -130), while also making the distance as small as possible.

What is the issue?
The result I get, is the part turning a lot before reaching the destination. I think what is happening here is the tween trying to start at 230 and keep going lower until it reaches -230, because the tween has no idea that what it’s tweening is an Orientation, it’s just a line of code.

What solutions have I tried so far?
I tried googling my issue, and I tried searching on the devforum, but both yielded no results. If you think you want to base off of, here’s some code.

local Part = workspace.Part
local TweenService = game:GetService("TweenService")
local TurnInfo = TweenInfo.new(
	2,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.InOut
)

-- Part orientation is 130
wait(5)

-- Rotate part smoothly
local Tween = TweenService:Create(Part, TurnInfo, {Orientation = Vector3.new(0, -130, 0)})
Tween:Play()

I don’t expect anybody to reply to this :frowning:

Well, I might not reply to the problem at hand. But I was compelled to read David Obstfeld’s thesis on mediation and separation brokerage. Very interesting, and thought provoking, what was the question again?

1 Like

Tween is incrementing or decreasing values linearly, so when it tweens the value from 130 to -130 it doesn’t go up until it reaches the other side, instead, it gradually goes down in value until it reaches -130.

So what you want to do is keep the part at 130 and add the necessary amount of orientation so it would end up on the other side, in this case, 100.

I added a repeat in TweenInfo so you can see it in action more than once.

local Part = workspace.Part
local TweenService = game:GetService("TweenService")
local TurnInfo = TweenInfo.new(
	2,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.InOut,
	-1,
	true
)

local Tween = TweenService:Create(Part, TurnInfo, {Orientation = Part.Orientation + Vector3.new(0, 100, 0)})
Tween:Play()