I have arms attached to the camera. But i want to lerp the rotation without lerping the position. How can i do that?
How can i only lerp the CFrames rotation?
1 answer
the following code lerps PartA's orientation to match PartB's orientation:
local PartA = workspace.PartA
local PartB = workspace.PartB
local start = PartA.CFrame
local _end = CFrame.new(PartA.Position) * (PartB.CFrame-PartB.CFrame.p)
for i = 0,1,.1 do
PartA.CFrame = start:Lerp(_end,i)
wait(.1)
end
This is the line of code that figures out what PartA with PartB's rotation would be:
local _end = CFrame.new(PartA.Position) * (PartB.CFrame-PartB.CFrame.p)
CFrame.new(PartA.Position)creates a CFrame consisting of only PartA's position and a rotation of (0,0,0).(PartB.CFrame-PartB.CFrame.p)subtracts the position from PartB's cframe so we are left with a cframe containing only PartB's rotation.
When you multiply CFrame.new(PartA.Position) and (PartB.CFrame-PartB.CFrame.p) you're left with a CFrame value containing PartA's position and PartB's rotation.
we can use that as the CFrame value as our 'end' position for the Lerp()
2 comments
Brilliant answer and explanation
thx.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
You can get only rotation without position with
cf - cf.PositionOh no I've still been using cf.p, I should probably curb that habit.
does that explain your question fully or do you need more help? also, camera doesnt have a camera.p, only camera.cframe.p so you're good on that end.