How to highlight objects when the player approaches in Unreal Engine 4/5
The highlight uses a Post Process Volume with an outline material and the Render Custom Depth Pass option of each object. In the object's Blueprint a Box Collision fires Begin Overlap, which calls Set Render CustomDepth to true, and End Overlap, which sets it back to false. A Boolean variable Highlight records whether it is active.
From the course
Taken from the hands-on project of the course; the lessons show every step on video.
How do I set up the Post Process?
- Add a Post Process Volume to the scene, anywhere. In Rendering Features, Post Process Materials, add an asset reference and pick the highlight material (M-Highlight).
- Select Infinite Extent (Unbound) so the volume affects the whole scene.
What does Render Custom Depth Pass do?
On a cube, search Depth in the Details panel and enable Render Custom Depth Pass under Rendering. The outline appears, but it is on all the time. With the view mode Buffer Visualization Custom Depth you see the silhouette stored in a buffer for that object only; the post process material uses it to draw the outline. Turn the option off to continue.
How do I make it appear on approach?
- Turn the cube into a Blueprint, Cube Blueprint, and add a Box Collision, enlarged so the character touches it.
- In the Event Graph delete the initial nodes, select the box and add the On Component Begin Overlap event.
- Ctrl-drag the Static Mesh component, call Set Render CustomDepth and set it to true on the begin overlap. Add On Component End Overlap and call it again with false.
Why a Boolean named Highlight?
After Set Render CustomDepth, create a Boolean variable Highlight and set it to true at the begin and to false at the end. It is not used yet, but it will be useful in the next exercises to know if the highlight is active.
How do I change the outline color?
Open the highlight material, find the color vector and double-click it to pick another color, such as blue. Save and test.
Free PDFs that go with this page
One-page guides made from the lessons, sent by e-mail.
- Interactive archviz delivery checklist — The things that go wrong in interactive scenes, checked one by one, each item tied to a lesson.
- Blueprint Cheat Sheet — A free one-page PDF for Unreal Engine 4/5, made from the lessons of the course. Keep it next to your editor while you learn.
- Free PDFs
Frequently asked questions
Why is my highlight always on?
Because Render Custom Depth Pass is enabled in the Details panel. Control it from the Blueprint instead.
Which events turn the highlight on and off?
Begin Overlap and End Overlap of the Box Collision.
What does the Post Process Volume do?
It applies the outline material to the whole scene when set to Infinite Extent.