# Mesh Distance Fields to Actor

**URL:** <https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779>\
**Category:** Blueprint\
**Tags:** distance-fields, unreal-engine, Blueprint, question\
**Created:** [January 12, 2024, 2:54pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779 "2024-01-12T14:54:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![AquaRex](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AquaRex](https://forums.unrealengine.com/u/AquaRex)\
**Post date:** [January 12, 2024, 2:54pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779/1 "2024-01-12T14:54:43Z")

</div>

Hi

I want to detect if the camera / or another object is inside a Mesh Distance field.  
And the logic being applied to it, is non-visual, so it’s not a material.

Is there a way to expose the distance field into blueprint?  
Or get the value from the material into a blueprint actor?

Thanks!

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 12, 2024, 3:09pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779/2 "2024-01-12T15:09:34Z")

</div>

You might need a rethink 🙂

The material node

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/2/d/f2db3916ebd5f3a4e1492888733985dcaaa1f238.png)

has a different value for every visible pixel of the material on the mesh. It’s not the distance of the mesh from something else.

You can get the distance of the camera to the object with

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/1/b/81ba7db53b7efd7eac12a7d48ff7070dbb47f2c7.png)

Can you give a specifc example?

---

<div class="post-metadata">

**Author:** ![AquaRex](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AquaRex](https://forums.unrealengine.com/u/AquaRex)\
**Post date:** [January 12, 2024, 3:14pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779/3 "2024-01-12T15:14:28Z")

</div>

Im aware of those material nodes. What I need to do is the “same” thing, but in blueprint;

I want to check if the camera is inside a Mesh Distance Field to play a certain sound and stop it if we’re outside of it. I was planning on using this to turn on / off “interior rain” sound as opposed to the exterior rain sounds when outside.

Most of my meshes that I’m using have decent MDFs setup anyway, so using this method would make it ( at least originally, in my mind ) an easy and decently consistent method of toggling the rain sounds based on if you are currently inside or outside the buildings.

Thanks!

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 12, 2024, 3:17pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779/4 "2024-01-12T15:17:34Z")

</div>

Most people would do that with an overlap volume. Any reason this is no good?

---

<div class="post-metadata">

**Author:** ![AquaRex](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AquaRex](https://forums.unrealengine.com/u/AquaRex)\
**Post date:** [January 12, 2024, 3:19pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779/5 "2024-01-12T15:19:19Z")

</div>

Not really…

I was just hoping for a more ‘streamlined’ solution that would work on all meshes since all have an MDF anyway lol. If this worked, It would save me alot of time now, and in the future when adding more of these meshes.

If there is no “easy” way to get the distance field distance value into blueprint, then I’ll probably do it with collision overlaps instead, but I was hoping to avoid it 😛

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 12, 2024, 3:21pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779/6 "2024-01-12T15:21:49Z")

</div>

Anything is possible, but I don’t this a great way to go about it.

The meshes have no code themselves, so the player has to decide which mesh is relevant, read the distance field and decide if they are inside it. How do they know which mesh to use, for example?

Hmm… 🕶

---

<div class="post-metadata">

**Author:** ![AquaRex](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AquaRex](https://forums.unrealengine.com/u/AquaRex)\
**Post date:** [January 12, 2024, 3:24pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779/7 "2024-01-12T15:24:12Z")

</div>

My thought about this, was to use it for anything that happens visually or audibly when you’re “inside” a building or object. Both are just effects and not gameplay related. The game is also in VR, so I figured if the effect gets applied when the player sticks their head through a mesh that wouldn’t be a bad thing anyway lol

Guess I’ll do it a different way. Thanks for the help anyway!

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 12, 2024, 3:27pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779/8 "2024-01-12T15:27:03Z")

</div>

I think the player is never actually in a mesh anyway…? 🤔

---

<div class="post-metadata">

**Author:** ![AquaRex](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AquaRex](https://forums.unrealengine.com/u/AquaRex)\
**Post date:** [January 12, 2024, 4:31pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779/9 "2024-01-12T16:31:41Z")

</div>

I guess it depends on the game. In this case, no. I wanted the distance from a mesh to be exposed in blueprint. Theres alot of potential from getting access to that outside of just material usage, theres already so much potential from the material side of things, but thats just visual.

I was hoping to gain access to it for audio and code purposes too.

---

<div class="post-metadata">

**Author:** ![quackcharge](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@quackcharge](https://forums.unrealengine.com/u/quackcharge)\
**Post date:** [January 8, 2025, 8:29pm UTC](https://forums.unrealengine.com/t/mesh-distance-fields-to-actor/1608779/10 "2025-01-08T20:29:40Z")

</div>

you could maybe do distance field queries in niagara modules and write out the result to blueprints with a callback handler
