Change color depending on a distance from another object.

Hi guys,

I would like to make the color of my shaded object change, as an object is near to it or far away.

I am using the distance node, plugging the ObjectPositionWs in the firt slot, but I would like to plug another object in the second slot, another that I can specify manually.
In order to modulate this, I was wondering to use some specific coordinates to use this area of effect, but I could find how to ?

f.e : I want my object -blue- to became slowly green when it is getting closer to specified coordinates (x,y,z). (that I specify, or using some object’s which another shader is)

Thank you for your help !

Hey BoUBoU -

Here is the basic setup you would need to do in the Event Graph to achieve the transition you are looking for. In the material of the object in the blueprint (for me it was Cylinder 0) all you need to do is set up a LERP between your two colors or textures and use a scalar parameter in a Material Parameter Collection as an Alpha.

Thank You

Eric Ketchum

EDIT: There is also materials included in Starter Content and the Content Examples which use a distance calculation to blend for LOD purposes which could be modified to also drive this same logic.

Thank you Eric very much, it helped me a lot !! :slight_smile: