How to tell what Vector3 the camera is looking at

Is there a way to find out the Vector3 of what the camera is looking at without detecting the player?

You could raycast with the origin being the camera position and the direction being the camera lookvector and raycast params that blacklist the player’s model

Is there a way to do this without using rays?

I can’t think of any other way. Why don’t you want to use raycasting?

local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
player.CharacterAdded:Wait()
local char = player.Character

local UIS = game:GetService("UserInputService")

local MaxDistance = 100

local RayParam = RaycastParams.new()

game:GetService("RunService").RenderStepped:Connect(function()
	local MousePos = UIS:GetMouseLocation()
	local LookVector = cam.CFrame.LookVector
	
	RayParam.FilterType = Enum.RaycastFilterType.Blacklist
	RayParam.FilterDescendantsInstances = {char}
	
	local result = workspace:Raycast(cam.CFrame.Position, LookVector * MaxDistance, RayParam)
	if result and result.Instance then
		print(result.Instance)
        print(result.Position)
        print(result.Normal)
	end
end)

^^^
Put this in a local script

If you meant the direction of the camera in Vector3 you can do this:

local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
player.CharacterAdded:Wait()
local char = player.Character

local UIS = game:GetService("UserInputService")

local MaxDistance = 100

local RayParam = RaycastParams.new()

game:GetService("RunService").RenderStepped:Connect(function()
	local LookVector = cam.CFrame.LookVector
        print(LookVector)
end)

That works if you print the direction, but this is what happens when i try pointing the character towards the camera direction using that.

https://i.gyazo.com/d710e0a6a2ff074415ecbff62c9c3ba5.mp4

Yea because it describes the direction not the point. You’d do like cam.CFrame.Position + cam.CFrame.LookVector

Look into the definition of a point on a ray

1 Like

Yes because it returns the look direction of the camera which is relative to camera and not relative to world position so its (x, y, z) studs away from the camera. Hope this helps :hugs:. also @CoderHusk is right. Sorry for the late reply I didn’t see this in my notifications :sob:.