BP - Get Material After Overlap not Working for Every Array Object

Hello,

I have a BP setup in my character blueprint that spawns a sphere mesh when i hit E key, a timeline scales the sphere and the sphere overlaps other objects as it expands, sets a different material, gets the original material and sets the original material back to the overlapped objects.

Here’s my overlap and set material setup;

Everything works as expected, however when it executes the second Set Material to switch to the original material, only the first overlapped object changes and the others stay with their set material. Here are 3 screenshots of the no overlap, overlap, and end of overlap phases of the event:

Is there a way to store the material of every overlapped object so that i can switch them back on after the 2 second delay? Let me know if i am too confusing and i’ll upload a video of the problem.

Thanks in advance!

does your project have a source folder? code based?

you could add a

TArray 

and expose it to blueprints and store the materials there

#Material Instance Dynamic Solution

Instead of just switching materials on and off

you could also consider using a material blend, between the original material and the highlighted/affected material

or you could just dramatically change color and brightness or change a texture or something liek that

then you could grab the material instance and set the alpha of the material blend between 0 and 1 based on where the sphere event is in relation to them.

this would save you from having to change materials and store their values somewheres

you’d also be able to do checks on any stray actors whose materials were not set properly by iterating over actors and checking out the status of their material blend alpha (ie, it is 1 when it should be 0)

Rama

#Creating and Storing the Materials Yourself

The advantage of a Material Instance Dynamic Solution (or even just changing the color and brightness of a material, dont have to blend two mats

is that since you are creating the instances yourself at runtime

you also know where they are stored at all times!

#Creating a BP Interface

to make this easy you could create a BP interface function for SetHighlightedOn and SetHighlightedOff

and then locally when each BP receives that event it will have its own material to refer to to adjust accordingly

you could use this solution for changing materials as well

then you dont have to store all the materials somewhere

if you use the function interface

you just pass out the signal to change mats and each BP handles the instruction in its own unique way

#Material Interfaces

https://rocket.unrealengine.com/docs/ue4/home/bitnami/answerhub/teamhub.home/depot/Support/Docs/Rocket/HTML/INT/Gameplay/Blueprints/UserGuide/Types/Interface/index.html

Thanks for the answers Rama!

Unfortunately i’m a caveman when it comes to programming so i’m using BP only.

As for material blending and MID;

The base material is opaque and the highlight material is translucent(so that i can disable depth test and see the objects behind other objects), so that doesn’t work with this as far as i know.

then see my BP interface idea above

you can then have each actor handle the even uniquely, switching materials or whatever you want :slight_smile:

you are not decentralizing the activity

you are actually taking it further

because the expanding sphere is essentially an Event

and now you are creating a function that all your actors have

to receive this event and handle it accordingly

saving you the need to save all the materials somewhere, since each actor will know its own material

:slight_smile:

Rama

Hmm, now you’ve given me another perspective. I’ll give it a go and see how it goes.
Thanks again! :slight_smile: