Yes, I made another ViewportFrame thing.
Before I begin…
Major shoutout to @Imaginaerum and @GollyGreg for making a wonderful highlighter library. I didn’t use it for this project, but it is what originally inspired me to make this. The library is absolutely fantastic, and it supports many usages. However, I needed a system optimized for this specific scenario. Go send them some love!
What is it?
This module allows you to highlight objects in an XRay fashion but only when visible within the bounds of a specified part. A bit hard to understand that, so it’s best I show you!
Inspired by Apex Legends, (the game that kills my productivity) this sight highlights the NPCs in the game.
You can use it for cool stuff like this enemy detector as well!
Notes:
I made this module really quickly, just for fun, and didn’t test beyond this base scenario shown here. Some of the code is actually untested. I’m sure there are plenty of cases where it fails. Be sure to let me know of these!
API:
------------------------------------------------------------------------------------
Module API:
function BoundsHighlighter:Start()
Description:
Enables the highlighter
Note:
Cannot be called until a BoundsPart is set via :SetBoundsPart()
function BoundsHighlighter:Stop()
Description:
Disables the highlighter
Note:
None
function BoundsHighlighter:Render(Model)
Description:
Adds a model to the rendering process
Note:
Designed for standard Humanoids, so it wont do Parts inside of Parts
function BoundsHighlighter:AddToIgnoreList(Instance)
Description:
Adds an instance to the ignore list of the visibility checks
Note:
None
function BoundsHighlighter:SetBoundsPart(BasePart)
Description:
Sets the part that will be used to calculate the bounds
Note:
The parts Front face must be facing the camera (at least mostly)
------------------------------------------------------------------------------------
Example Usage:
for i, npc in pairs(workspace.NPCs:GetChildren()) do
BoundsHighlighter:Render(npc)
end
BoundsHighlighter:SetBoundsPart(FPSViewModel.Sight)
BoundsHighlighter:AddToIgnoreList(FPSViewModel)
BoundsHighlighter:Start()
------------------------------------------------------------------------------------
Source:
Uncopylocked and Public Place:
GitHub:
Roblox Library: