# Changing Overlay Material Max Draw Distance?

**URL:** <https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [April 9, 2025, 9:48pm UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722 "2025-04-09T21:48:35Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmaiTrick](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AmaiTrick](https://forums.unrealengine.com/u/AmaiTrick)\
**Post date:** [April 9, 2025, 9:48pm UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/1 "2025-04-09T21:48:35Z")

</div>

So I have a setup where I am spawning 20ish actors from the same class using a line trace to put them randomly in an area around the player (Line trace into spawn actor, looped 20 times). I have a button that turns on an overlay material so the player can see where the items are. At the start of the game I want it to randomly decide how far away the player can see the overlay from (Max Draw Distance).

But when I set it up it doesn’t _seem_ to be changing the distance at all.

Here’s what I have for trying to change the overlay material, it’s probably not well set up but it’s the only way I could think to do it.

 ![OverlayMaterial](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/b/77b3ee773246e01b7db61fb1767b51588c250add.png)

If I place the actor that is using the overlay into the world, the draw distance change works. But if I try it with the spawned in actors it won’t change anything.

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [April 9, 2025, 11:19pm UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/2 "2025-04-09T23:19:08Z")

</div>

First, in this loop it seems “keen\_eye\_stat” variable is in one state (0 or 1).  
That means all meshes will be 1000 or 2000 max draw distance.  
No idea what set overlay material max distance do.

---

<div class="post-metadata">

**Author:** ![AmaiTrick](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AmaiTrick](https://forums.unrealengine.com/u/AmaiTrick)\
**Post date:** [April 9, 2025, 11:24pm UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/3 "2025-04-09T23:24:19Z")

</div>

That’s intentional. I’m trying to get it to set to 1000 or 2000 (there’s more to the right) depending on if the Keen Eye Stat is 0, 1, 2, etc. It’s working when placing the actor directly into the level but not when it spawns them in with the Spawn Actor node.

The code wiring is a bit messy, sorry. Basically it’s looking at the mesh to change, checking if Keen Eye Stat is set to 0, and if it is sets the distance to 1000. If it is not 0 (false) it goes to check if Keen Eye Stat is set to 1. If it is, it sets distance to 2000. So on, so forth. Likely a bad way to do it but it _is_ working if I put the actor directly into the map.

(Setting overlay material max distance changes how far away you can see the outline from the overlay material)

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [April 9, 2025, 11:28pm UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/4 "2025-04-09T23:28:42Z")

</div>

Where is this code executed? Level blueprint? On begin level? Need more context.

---

<div class="post-metadata">

**Author:** ![AmaiTrick](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AmaiTrick](https://forums.unrealengine.com/u/AmaiTrick)\
**Post date:** [April 9, 2025, 11:30pm UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/5 "2025-04-09T23:30:14Z")

</div>

It’s in the player blueprint.

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [April 9, 2025, 11:34pm UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/6 "2025-04-09T23:34:45Z")

</div>

Do a print string at the end of set overlay material max draw distance. Does it print string.

---

<div class="post-metadata">

**Author:** ![AmaiTrick](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AmaiTrick](https://forums.unrealengine.com/u/AmaiTrick)\
**Post date:** [April 9, 2025, 11:57pm UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/7 "2025-04-09T23:57:57Z")

</div>

It is not giving the message from print string at all.

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [April 10, 2025, 12:01am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/8 "2025-04-10T00:01:53Z")

</div>

Put print string right at the beginning of loop body.

---

<div class="post-metadata">

**Author:** ![AmaiTrick](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AmaiTrick](https://forums.unrealengine.com/u/AmaiTrick)\
**Post date:** [April 10, 2025, 12:05am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/9 "2025-04-10T00:05:59Z")

</div>

I’m so sorry my dumb butt forgot I have multiple outcomes. Print string at the end of the max draw distance DOES return a message.

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [April 10, 2025, 12:07am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/10 "2025-04-10T00:07:37Z")

</div>

The same number as number of actors?

---

<div class="post-metadata">

**Author:** ![AmaiTrick](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AmaiTrick](https://forums.unrealengine.com/u/AmaiTrick)\
**Post date:** [April 10, 2025, 12:09am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/11 "2025-04-10T00:09:45Z")

</div>

If I drag out of Array Index in for each loop to connect to the print string it should show me the number it gets right?

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [April 10, 2025, 12:11am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/12 "2025-04-10T00:11:18Z")

</div>

Maybe. Try it.

---

<div class="post-metadata">

**Author:** ![AmaiTrick](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AmaiTrick](https://forums.unrealengine.com/u/AmaiTrick)\
**Post date:** [April 10, 2025, 12:13am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/13 "2025-04-10T00:13:28Z")

</div>

Wait hang on this helped I realize I have it connected to begin play not something like event tick, so it’s only setting it at the start of the level before the berries spawn not any time the berries spawn. If I set it to event tick it returns all the actors as they spawn! I feel so dumb. Let me check if this is actually changing the distance or not…

_Edit_

Yes this is working! The answer was I was connecting it to the wrong thing. Thank you so much!!

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [April 10, 2025, 12:15am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/14 "2025-04-10T00:15:32Z")

</div>

Static mesh?

---

<div class="post-metadata">

**Author:** ![AmaiTrick](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AmaiTrick](https://forums.unrealengine.com/u/AmaiTrick)\
**Post date:** [April 10, 2025, 12:17am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/15 "2025-04-10T00:17:51Z")

</div>

No I had the whole code on Begin Play, so it was trying to set the draw distance of the non existent actors before they spawned. I set it to event tick (for now, might find a better solution later) and it now sets them any time they spawn.

Thanks again! The print string helped me figure that out.

---

<div class="post-metadata">

**Author:** ![Dejan33](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dejan33/32/1194514_2.png) [@Dejan33](https://forums.unrealengine.com/u/Dejan33)\
**Post date:** [April 10, 2025, 12:23am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/16 "2025-04-10T00:23:13Z")

</div>

Glad you figured it out. Only do this loop when you need to(if you are doing it on tick(like when you change"keen eye stat" variable state or something)).  
Also, either give a 0.3 seconds delay OR check if all actors are actually spawned before you do this loop. That’s all.

---

<div class="post-metadata">

**Author:** ![AmaiTrick](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AmaiTrick](https://forums.unrealengine.com/u/AmaiTrick)\
**Post date:** [April 10, 2025, 12:23am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/17 "2025-04-10T00:23:58Z")

</div>

Yeah the event tick is a temp solution, I’ll likely trigger this code on the use of the Keen Eye ability so it’s only running once when the ability is activated

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [May 10, 2025, 12:24am UTC](https://forums.unrealengine.com/t/changing-overlay-material-max-draw-distance/2448722/18 "2025-05-10T00:24:54Z")

</div>

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