I am currently trying to create a transition effect, where you look at a part that engulfs your whole screen, and then teleports you in a way that you can look behind and be in a different room. For example, something like this
but where this would not trigger anything since you can see the surrounding environment thus making it not seamless
Not sure if this is the most practical answer, but you could use Camera:ScreenPointToRay on each corner of the screen. If all 4 rays hit the same part, then it is engulfing the screen. You could also check the distance and normals so that it is aligned correctly.
I’m testing it with the top left, seems to be doing nothing intentional. I can’t even tell what it’s doing wrong, all I know is that my origin is correct
--!strict
local camera = workspace.Camera
local cameraSize = camera.ViewportSize
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {workspace:WaitForChild("Joshument")}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
while true do
task.wait(0.1)
local topLeftRay = camera:ScreenPointToRay(0, 0, 1)
--[[
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.one
part.Position = topLeftRay.Origin
part.CanCollide = false
part.Transparency = 0.5
part.Parent = workspace
]]
local topLeftRaycast = workspace:Raycast(topLeftRay.Origin, topLeftRay.Direction)
if topLeftRaycast then
print(topLeftRaycast.Instance.Name)
end
end
Looks like I got it to work, I’m just assuming the Ray that’s returned is a Unit vector and I needed to increase how far the vector traveled
--!strict
local camera = workspace.Camera
local cameraSize = camera.ViewportSize
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {workspace.TestFolder, workspace.TestFolder.TestPart}
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
while true do
task.wait(0.1)
local topLeftRay = camera:ScreenPointToRay(0, 0, 0)
local topLeftRaycast = workspace:Raycast(topLeftRay.Origin, topLeftRay.Direction * 100, raycastParams)
if topLeftRaycast then
print(topLeftRaycast.Instance.Name)
end
end