I’ve spent countless hours trying to figure out what’s going on here. If anyone has any ideas, it would be greatly appreciated.
The script takes 4 positions, gets the center position, then uses CFrame.fromMatrix to create the CFrame with the correct orientation.
Everything is fine with the calculation as far as I know. If I set the CFrame without using TweenService, everything is correct. In my mind, a CFrame is a CFrame. The calculation of getting the CFrame shouldn’t matter.
local TweenService = game:GetService("TweenService")
local MovePart = game.Workspace.MovePart
local TopLeft = game.Workspace.TopLeft.Position
local TopRight = game.Workspace.TopRight.Position
local BottomLeft = game.Workspace.BottomLeft.Position
local BottomRight = game.Workspace.BottomRight.Position
local Center = (TopLeft + TopRight + BottomLeft + BottomRight) / 4
local BottomAvg = (BottomLeft + BottomRight) / 2
local CenterCF = CFrame.fromMatrix(Center, TopRight - TopLeft, TopLeft - BottomAvg)
local goal = {}
goal.CFrame = CenterCF
local tweenInfo = TweenInfo.new(5)
local tween = TweenService:Create(MovePart, tweenInfo, goal)
tween:Play()
I’ve figured out that something is wrong with your tweening which is something I’m not sure how to fix but I’ve found another fix. This isin’t CFrame but it’s something you can use.
local Center = (TopLeft + TopRight + BottomLeft + BottomRight) / 4
local goal = {}
goal.Position = Center
local tweenInfo = TweenInfo.new(5)
local tween = TweenService:Create(MovePart, tweenInfo, goal)
tween:Play()
This instead takes the centre which I printed out and tested and replaces it with position instead of CFrame.
Thanks for the reply. I would use Vector3 instead of CFrame if the 4 cubes were always at that same angle, but I need it to work no matter where the cubes are positioned. It has to be something with how I calculated the CFrame. Just gonna take a break for a bit and do some more testing tomorrow. Literally wasted the whole day trying to figure this out lol.
Well it’s not your fault. When printing and testing the CFrame values, they align exactly to how you wanted it to be at the end.( except for the orientation you calculated I think)
Yeah, that’s why I’m so confused. I’ve had hundreds of problems on my journey developing this game and I’ve solved every one of them through time. This time I’m just absolutely lost. It’s starting to seem like a roblox bug. Even using :Lerp I get the same results, the same rotation and then right at the end it snaps to being correct.