How do I make the player's outline visible when behind a wall?

How exactly would I go about doing this? I’ll probably have to use Roblox’s new ‘Highlight’ instance to achieve this, but I don’t really know how to detect a if a player is behind a wall.

1 Like

you can use Camera:GetPartsObscuringTarget to see if the target is behind a wall

local castPoints = {character.PrimaryPart.Position}
local ignoreList = {character}
local parts = workspace.CurrentCamera:GetPartsObscuringTarget(castPoints, ignoreList)
if #parts == 0 then
    print("nothing is obscuring")
else
    print(#parts, "parts obscuring")
end

its also possible to do with Intro to Raycasting this might be a tinny bit better with performance then GetPartsObscuringTarget

local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character}

local position = workspace.CurrentCamera.CFrame.Position
local direction = character.PrimaryPart.Position - position

local raycastResult = workspace:Raycast(position, direction, raycastParams)
if raycastResult == nil then
    print("nothing is obscuring")
else
    print(raycastResult.Instance, "is obscuring")
end
6 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.