Hello there, I would like to detect if player is looking to the sky or to the ground,
This maybe will include trigonometry but I don’t really know how could I do that.
If anyone know how can I do that please reply!
Hello there, I would like to detect if player is looking to the sky or to the ground,
This maybe will include trigonometry but I don’t really know how could I do that.
If anyone know how can I do that please reply!
Maybe this could be want you want? Since the sky would be nil
(I’m guessing or an actual skybox) you could do something like this in a LocalScript
?
local RunService = game:GetService("RunService")
local SkyPosition = Vector3.new(0, 100, 0)
local GroundPosition = Vector3.new(0, 0, 0)
RunService.RenderStepped:Connect(function()
local Camera = workspace.CurrentCamera
local SkyVector, SkyDetect = Camera:WorldToViewportPoint(SkyPosition)
local GroundVector, GroundDetect = Camera:WorldToViewportPoint(GroundPosition)
if SkyDetect then
print("The player is looking at the sky!")
elseif GroundDetect then
print("The player is looking at the ground!")
else
print("The player is looking somewhere else!")
end
end
end)
This is just a edgy example, but this is how you’d maybe do it