I am trying to convert my mouse.Hit CFrame in my code to an inputobject position and im not sure how to go about it.
function GetMousePoint(X, Y)
local RayMag1 = Camera:ScreenPointToRay(X, Y)
local NewRay = Ray.new(RayMag1.Origin, RayMag1.Direction * 1000)
local Target, Position = workspace:FindPartOnRay(NewRay, game.Workspace.TargetFilter)
return Position
end
function CamHandling:InputUpdate(x, y)
--CAMERA LOOK
local LookPoint = GetMousePoint(x, y)
local CameraDirection = Root.CFrame:toObjectSpace(LookPoint).lookVector
if Neck then
if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
Neck.C0 = CFNew(0, YOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)
elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
Neck.C0 = CFNew(0, YOffset, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(CameraDirection.x)) * CFAng(-asin(CameraDirection.y), 0, 0)
end
end
game.ReplicatedStorage.Look:FireServer(Neck.C0)
end
this is what i have right now, however it doesn’t have the full properties of a CFrame and i’m not sure how to go about getting them for an inputobject position.
Any help is appreciated