Rotate a part to the camera's orientation, smoothly and slowly

Im not strong in cframe, or math. so Im gonna ask some of you guys to help me out here.

Yes i have the base of it working, it rotates to the camera’s orientation, but it doesnt do it smoothly or slowly.

I want it to look to the camera’s orientation while like slowing down slowly as it reaches its destination.

image

A example of how smooth i want it to be like:

Would appreciate a response, this seems like a rather easier thing to fix.

Can you send the script that controls “it”?

Sure.

game:GetService("RunService").Heartbeat:Connect(function(dt)
	local camOrientation = game.Workspace.Camera.CFrame-game.Workspace.Camera.CFrame.Position;
	game.Workspace.RotCenter.CFrame = CFrame.new(game.Workspace.RotCenter.Position)*camOrientation
end)

You can do this using tweens (adjust time to your liking) (fire this every time orientation changes)

local ts = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.In)
local tween = ts:Create(game.Workspace.RotCenter, tweenInfo, {CFrame = CFrame.new(game.Workspace.RotCenter.Position)*camOrientation}
tween:Play()

try this

local currentTween
local ts = game:GetService("TweenService")

workspace.CurrentCamera:GetPropertyChangedSignal("Orientation"):Connect(function()
	local camOrientation = workspace.CurrentCamera.Orientation
    if currentTween then currentTween:Stop() end
    currentTween = ts:Create(workspace.RotCenter, TweenInfo.new(3, 3), {CFrame = CFrame.new(workspace.RotCenter.Position)*camOrientation})
    currentTween:Play()
end)

im not good at this either lol

I didnt literally mean tweens, I heard from people thats a bad practice, is there any other way?

I remember theres like a equation that calculates or something, and it slows down as it reaches the target, creating a fast to slow effect (not a actual tween), do you guys know how to do that?

You too by the way, do you know how to do that?

You might be thinking of Lerp, but it’s similar performance-wise to Tweens. Also Tweens itself doesn’t hurt performance, if it is deleted after usage then it’s completely fine. Other than Lerp and Tweens, there probably is no other way to make it smooth. (move the TweenInfo out of the function by the way)

I really prefer lerp, do you know how to do lerp on this?
Thank you for reminding me btw, grass… person…?

Lerp is much more complicated than Tween and is implemented through a loop. You can do this by using alpha (yeah…)

local timeToTake = 1 -- the amount of time to take
local alpha = 0 -- what the alpha starts at
local startCFrame = workspace.RotCenter.CFrame
local goalCFrame = CFrame.new(game.Workspace.RotCenter.Position)*camOrientation

while alpha < 1 do
	workspace.RotCenter.CFrame = startCFrame:Lerp(goalCFrame, alpha)
	-- increment alpha based on how long wait() takes so that it'll be 1
	alpha = alpha + (wait() / timeToTake)
end

try this lerp script:

local co

workspace.CurrentCamera:GetPropertyChangedSignal("CFrame"):Connect(function()
    if co then coroutine.yield(co) coroutine.close(co) co = nil end
    co = coroutine.create(function()
        local increment = 0.1
        local camOrientation = workspace.CurrentCamera.CFrame-workspace.CurrentCamera.CFrame.Position
        for i = 0, 1, increment do
            increment += 0.1
            increment = math.clamp(increment, 0, 1)
            workspace.RotCenter.CFrame:Lerp(CFrame.new(workspace.RotCenter.Position)*camOrientation, i)
            task.wait()
        end
    end)
    coroutine.resume(co)
end)

Tried this, I dont know how to implement it in the code, and when i think i did it right, it only did it once then stopped.

my bad, i edited it now

(sorry)

Same error, Orientation isnt a valid property of CurrentCamera

i dont think you updated the script, because I didnt even use CurrentCamera there, so try updating it

Change it to GetPropertyChangedSignal(“CFrame”)

It’s just an example, put it in a GetPropertyChangedSignal connection like what remcodes did and change the property to CFrame