Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making a part transparent if in between camera and character by raycast?

Asked by 4 years ago

I'm working on a faux-isometric game and the biggest problem I've had so far is making sure the player character can always be seen. I've managed the problem so far by just using Touched and TouchEnded to detect if a roof or wall needs to be made transparent in order to not obstruct the camera, however it isn't very effective when multiple characters are present.

I decided that using rays to just detect any parts between the player and the camera would probably work a bit better, however I'm not very well versed with rays and the references Roblox has on them aren't very good.

The script gives this error:

Workspace.MamaGobies.Script:10: attempt to index local 'part' (a nil value)

wait(2)
local character = script.Parent

while wait(1) do
    local Ignore = character
    local Start = character.Torso.CFrame.Position
    local Vector = game:GetService("Workspace").CurrentCamera.CFrame.Position - Start
    local ray = Ray.new(Start, Vector)
    local part = workspace:FindPartOnRay(ray,Ignore)
        if part:IsA("Part") then
            part.Transparency = 1
    end
end

For reference, this is the camera's fixed location. http://prnt.sc/qejm8g

0
I don't suppose simply setting 'DevCameraOcclusionMode' to 'Invisicam' form tarterPlayer would work, would it? (game.StarterPlayer.DevCameraOcclusionMode =Enum.DevCameraOcclusionMode.Invisicam) mbramblet 80 — 4y
0
If the camera is the local Player's Camera then I recommend using "workspace.CurrentCamera:WorldToScreenPoint()" ryan32t 306 — 4y

Answer this question