Object "X-Ray/Highlighting" System

This looks exactly like Soldier 76’s ultimate in Overwatch haha, I like it!

2 Likes

I’m pretty sure they easily just inserted SurfaceGuis for each side of the character then made it AlwaysOnTop, since the models are all squares which is much more simpler.

I’ve been working with @Imaginaerum on the project to get it feature-ready for use in real games.

Features a new api, examples. Base code is the same, but reorganized. Read me has been upgraded.

Please fill out any Issues on the repository page if anything arises.

1 Like

Very nice.

I plan on making a few demos of this just to play around, so I’ll be sure to post them here.
Thank you for your contribution to the community!

1 Like

We should showcase demos on the project page if you ever have them hosted somewhere.

This is fun!

I made an extremely rough prototype of a “Digital Threat” scope, inspired by Apex Legends.

It checks if the object is within a GUI (the red dot gui) using WorldToScreenPoint, and then does a single raycast to check if the part is obscured.
If the part is in the gui and visible, it updates the highlight and makes it visible.

Plenty of bugs to work out here, but I wanted to show a cool usage idea.

External Media

Edit: Forgot to include my code :man_facepalming:t2:

{
		onBeforeRender = function(_, _)
			return true
		end,

		onRender = function(_, worldPart, viewportPart, highlight)
			--Only update within frame
			local v,oS	= Cam:WorldToScreenPoint(worldPart.CFrame.Position)
			if oS and insideGUI(v, gui) then
				--Only update if not obscured
				local blockingPart = workspace:FindPartOnRay(Ray.new(Cam.CFrame.Position,(worldPart.CFrame.Position - Cam.CFrame.Position).unit * 500), Cam)
				if blockingPart and not blockingPart:IsDescendantOf(worldPart.Parent) then
					viewportPart.Transparency	= 1
				else
					viewportPart.Transparency	= worldPart.Transparency
					viewportPart.CFrame			= worldPart.CFrame
					viewportPart.Color			= highlight.color
				end
			else
				--not within gui
				viewportPart.Transparency = 1
			end
		end,

		onAdded = function(_, viewportPart, highlight)
			local function clearTextures(instance)
				if instance:IsA("MeshPart") then
					instance.TextureID = ""
				elseif instance:IsA("UnionOperation") then
					instance.UsePartColor = true
				elseif instance:IsA("SpecialMesh") then
					instance.TextureId = ""
				end
			end

			local function colorObject(instance)
				if instance:IsA("BasePart") then
					instance.Color = highlight.color
				end
			end

			for _, object in pairs(viewportPart:GetDescendants()) do
				clearTextures(object)
				colorObject(object)
			end
			clearTextures(viewportPart)
			colorObject(viewportPart)
		end,
	}

Edit: Made a simple library dedicated to this

9 Likes

That’s actually sick dude! Nice to know I’m not the only one who creates things inspired from Apex Legends lol.

3 Likes

I actually replicated Bloodhound’s tactical ability using this; the Eye of the Allfather. That thing that momentarily reveals the location of nearby players at the time of the use.

2 Likes

That’s what I was going to do next but I guess you beat me to that one :stuck_out_tongue_winking_eye::yum:

3 Likes

We’ve included a release page with a precompiled RBXM file and Roblox Marketplace Asset link for those who had issues compiling this code themselves with rojo or would rather code inside of Roblox Studio.

4 Likes

uhh is this still up to date? I haven’t been able to get it working-

It doesn’t work, it’s been two years.

1 Like

This should still work :slightly_smiling_face: I would recommend downloading the rbxm from the releases page and trying it out with the example code in the first post

3 Likes

Sorry for disturbing you, but is it possible to have an x-ray outline, kind of like in hitman 3?
A bit like this

2 Likes
5 Likes

Oh, perfect! Thanks for helping me out.

Thank you for your contribution to the community! I will use in my projects.

Would this work on people? For example say Im making a team-based game and want it so you can see your teammates through walls. Would I be able to do this?

Hi, sorry. I can’t figure out :removeFromStack(), for some reason this function doesn’t work at me. You can help me?

My script:


local myCustomRenderImpl = (function()


	return function()

		return {
			onRender = function(_, worldPart, viewportPart, highlight)
				viewportPart.CFrame = worldPart.CFrame
				viewportPart.Color = highlight.color
			end,
		}
	end
end)()


local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local ObjectHighlighter = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("ObjectHighlighter"))

local myScreenGui = script.Parent
local myRenderer = ObjectHighlighter.createRenderer(myScreenGui):withRenderImpl(myCustomRenderImpl)



ReplicatedStorage.Remote.Events.Highlighter.OnClientEvent:Connect(function(Object,Action)
	local myHighlight = ObjectHighlighter.createFromTarget(Object)
	myHighlight.color = Color3.fromRGB(255, 234, 0)

	local function Add()
		myRenderer:addToStack(myHighlight)
	end
	
	local function Remove()
		myRenderer:removeFromStack(myHighlight)
	end
	
	if Action == "Add" then
		Add()
	elseif Action == "Remove" then
		Remove()
	end
end)

RunService.RenderStepped:Connect(function(dt)
	myRenderer:step(dt)
end)

This is no longer required, as Roblox released the Highlight object for this purpose some time ago.