Problem with CFrame

Hello, i’m making a Framework and i’ve got a problem
how do i change position without changing Orientation in CFrame?
WHAT I WANT TO ACHIEVE
https://i.gyazo.com/09912f49d6cf84ac968f1e1e2e4a5f20.mp4

WHAT I CURRENTLY HAVE
https://i.gyazo.com/5d428837ab15c0db69b12048d88a5997.mp4

SCRIPT

while RUS.RenderStepped:Wait() do
	--<<
	A.HA.CFrame = A.HA.CFrame:Lerp(workspace.CurrentCamera.CFrame, 0.25)
end

thanks for helping

1 Like

Before repositioning you could use the getComponents method on the current CFrame, then reconstruct a new cframe using the new position, and the old orientation components.

Reference for usage:

hope that helps!

It’s doesn’t work, did i got it wrong or what?

while RUS.RenderStepped:Wait() do
	local AHewq = A.HA.CFrame:GetComponents()
	A.HA.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position, AHewq.LookVector)
	A.HA.CFrame = A.HA.CFrame:Lerp(workspace.CurrentCamera.CFrame, 0.25)
end

h

getComponents returns a bunch of values, so you cannot put them into one variable (check the link i posted previously)

If you just want the lookvector you could use what you just posted, but instead of using getcomponents just use OldCFrame.LookVector to construct the new CFrame

You are lerping two CFrames with different rotations, so perhaps you want to lerp the positions of the CFrames first then adjust A.HAs CFrame using that position which can be done subtracting the position from the CFrame then Adding back another position (or subtracting the oldvec by the new)

local CameraPos = workspace.CurrentCamera.CFrame.Position
local Position = A.HA.Position:Lerp(CameraPos, .25)

A.HA.CFrame = A.HA.CFrame + (Position  - A.HA.CFrame.Position)

But, If you really wanted to lerp the CFrames (which i don’t see a huge reason to, since you are trying to maintain orientation i believe) you can use the position of the CFrame to change A.HAs CFrame:

local CF =  A.HA.CFrame:Lerp(workspace.CurrentCamera.CFrame, 0.25)
A.HA.CFrame = A.HA.CFrame + (CF.Position - A.HA.CFrame.Position)

Also now that i’m looking at it, since i’m guess A.HA is a part, is there a reason you can’t change A.HAs position instead of its CFrame? (which would maintain orientation)

If i change Position property, something wrong happening with parts that was welded on this A.HA part