Attachment not translating well with camera CFrame orientation

So i have these two snippets of code in which they control the camera.

-- CLIENT --
while true do 
	local X,Y,Z = Camera.CFrame:ToOrientation()
	CAMERAROTSEND:Fire(CFrame.Angles(X,Y,Z))
	RunService.Heartbeat:Wait()
end
-- SERVER --
CAMERAROTRECIEVE:Connect(function(pl, Rotation: CFrame)
	local PositionONLY = TorsoAttachment.CFrame.Position
	local newCFrame = CFrame.new(PositionONLY) * Rotation
	TorsoAttachment.CFrame = newCFrame
end)

the problem is that the rotation does NOT translate well with the camera orientation.
https://cdn.discordapp.com/attachments/1160471723376910410/1227161658632441856/2024-04-09_15-27-39.mov?ex=6627665a&is=6614f15a&hm=8dc80574d8d5c5728a274330d8954c1b609b621086a382b43e9781fb697eeab6&

1 Like

“* Rotation” actually ads position to the cframe instead of rotation. What you could do instead is give the Camera.CFrame.LookVector and reconstruct the cframe as

newCFrame = CFrame.lookAlong(PositionONLY, CameraLookVector)

tried this solution out, it did fix some problems, but its inverted (no clue how to un-invert the thing).

EDIT: I got it fixed by making the X and Z axis negative, thank you!

Yaaay, Camera’s look vector is the direction the camera is pointing to, if you want the opposite then it would be negative, like -Camera.CFrame.LookVector.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.