Hello everyone. I wanted to know how I could rotate a CFrame to a surface normal.
function Camera:AlignToSurface(result: RaycastResult)
self.Instance.CFrame *= CFrame.fromRotationBetweenVectors(
self.Instance.CFrame.UpVector,
result.Normal
)
self.Instance.CFrame =
self.Instance.CFrame.Rotation + result.Position + result.Normal
self.OrthagonalBasis = self.Instance.CFrame.Rotation
self.Yaw = 0
self.Pitch = 0
self.Roll = 0
end
This is a function I’m using in a custom Camera class.
Note that: self.Instance = workspace.CurrentCamera
The camera isn’t parallel with the surface normal.
Is this because of some inaccuracy when using CFrame.fromRotationBetweenVectors
?