TweenService plays unecessary 360 turns

Hello , Recently I’ve been using TweenService to Tween the Orientation of a Part.
Now, when i do so, about half of the time, it makes an unnecessary 360 degrees turn, or in general
takes the longest “route” to the final result of the Tween.

This is a clip that shows the part being tweened every 1 second, it tweens its position and orientation towards the next “Node”

In The first route, the part already has the same orientation as the next node, aka its already facing the node, but the Tween is ran eitherway. the problem is, instead of not changing, or just changing by a degree, it make a full 360 every time, now this doesnt happen only when the orientation is the same, it happens even for 90 degrees turns, This is the function that handles it. how can i fix this?

local function TweenOrientation(Part,Time,Value)
	local TweenInfo = TweenInfo.new(Time,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
	local Tween = TweenService:Create(Part,TweenInfo,{Orientation = Value})
	Tween:Play()
	return Tween
end 

I tried using In Out InOut, and different Easing styles, but nothing changes,

Any suggestions are appreciated!

OwKZqOFQ5m

Note: The first route looks like he is going insane because of the difference in framerate i recorded it with, he is actually spinning as doing a 360 turn would look like

2 Likes

It is iconic as it gives 360 degrees and then when it moves to the side it is all calm

but… im sorry i dont know much about scripting things

1 Like

I was working on something similar to this but for rotation at turns. I used CFrame for mine.

local CFrameData = CFrame.new(ParentNode.Position, Node.Position)
	local RotationTween = TweenService:Create(Entity, TweenInfo.new(RotationSpeed, Enum.EasingStyle.Linear), {CFrame = CFrameData})
		RotationTween:Play()
			RotationTween.Completed:Wait()

TLDR: Tween the Enemy CFrame at the next node but make sure the Node that it’s moving to has it’s front surface facing the direction that you want the node to rotate in.

Visual representation:

3 Likes

Yeah i can try using CFrame, i didnt think about it, but my framework can allow me to use 1 tween, only for 1 CFrame, i got a good feeling about this, ill see how it goes , Thank you

1 Like

It Worked!, thanks a lot for the help, im also going to try CFrame:Lerp() and see how that one goes

1 Like