The Highlight effect is a pretty recent addition to Roblox Studio. It looks really awesome and has some useful properties that you may expect, such as an outline color and fill color property. Despite this, there is no MaxDistance render behavior you would expect from something like a BillboardGui. Instead, you can see Highlighter effects from miles away:
I put together this simple class called ExtendedHighlight to solve this issue.
The code is fairly simple, with a constructor and a couple getters/setters:
function ExtendedHighlight.new(maxDistance, highlight, parent)
local extendedHighlight = setmetatable({}, ExtendedHighlight)
extendedHighlight._maxDistance = maxDistance or DEFAULT_MAX_DISTANCE
extendedHighlight._highlight = highlight
if parent then
highlight.Parent = parent
end
table.insert(highlighters, extendedHighlight)
return extendedHighlight
end
It’s super easy to edit and add to if anyone wants. I created this because I feel like it’s a missing feature, but I expect Roblox will be adding it eventually. This is just for anyone that wants to use them.
The distance is calculated relative to the camera + This code is meant to be inside of a module. You are also meant to “inject” a highlighter instance to extend with the max distance behavior, but you can edit the code if you don’t like calling ExtendedHighlight.new() and Instance.new() back to back. And finally, if it wasn’t obvious to anyone already, this code can only be run on the client since we’re dealing with local camera positions.
Heres an example of what it might look like in code:
local ExtendedHighlight = require(script.ExtendedHighlight)
local dummy = workspace:WaitForChild("DummyA")
local highlight = Instance.new("Highlight")
highlight.OutlineColor = Color3.fromRGB()
highlight.FillColor = Color3.fromRGB()
-- in studs, of course
local maxDistance = 30
-- the parent property (third property) is not entirely necessary and just for shortcuts
local extendedHighlight = ExtendedHighlight.new(maxDistance, highlight, dummy)
-- eg, you might wanna quickly create an extended highlight:
local otherHighlight = ExtendedHighlight.new(15, Instance.new("Highlight"), workspace.DummyB)
-- function calls
extendedHighlight:SetEnabled(false)
extendedHighlight:SetEnabled(true)
print(extendedHighlight:GetMaxDistance())
print(extendedHighlight:GetHighlight().Name)
extendedHighlight:Destroy()
The ExtendedHighlighter in action:
The nice thing about this piece of code is that its self contained and fairly optimized. I’m not sure how expensive it is to bind things to render step like this, but I don’t imagine it’s too computationally expensive.
Let me know if there are any bugs and I’ll edit the paste link with an updated version