Mesh Distance Fields to Actor

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!

You might need a rethink :slight_smile:

The material node

image

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

Can you give a specifc example?

1 Like

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!

1 Like

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

1 Like

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 :stuck_out_tongue:

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… :sunglasses:

1 Like

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!

1 Like

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

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.

1 Like