[SOVLED] Dynamic Material won't change in game during runtime

SOLUTION: I had to call the function from an event graph. It did not work being called from another function. I used an event call instead.

I have a dynamic material that I am trying to change at run time. If I attach the function to the event begin play it works correctly. If I use an overlap it works correctly. However it does not work correctly when called from another script, such as after you capture the area.

Here is the code to create and set a dynamic material:

Here is the code to change the color:


When calling from the event begin play here is the result:

As you can see the teleport ring is blue and element 1 is blue which is correct.

Here is the call once the capture point it captured:

It works and changes element 1 to blue which is correct but the teleport ring stays white as seen here:

I am not sure why it works on the event begin play or an overlap but not when called from another function. Thanks

Did you forget to choose source material to make the dynamic instance out of? The dropdown has no asset.

I tried it without a source material, I tried with with the instance material and I tried it with the parent material. Nothing works for the function call.

Set the source material as Element 1 (MaterialInstanceDynamic_0). Get static mesh, get material (index 1).
Said material needs to have the parameter TeleportColor which will change the base color.

Another thing. Make sure your function variables Teleport 2MID are not Local variables.

Create the DMI in the construction script of the actor being changed (Transporter).

Change Color Function

Revert Color Function

Simple Triggering … pawn begins/ends overlap transporter box collision


I changed the source material to get the source material from the static mesh. I also made sure the variable is set to public. It still doesn’t work. Please note that it does work when using overlaps but that is not what I need. I need to call the function when the point is captured.

This means the DMI functionality is set up correctly. You now just need a way to communicate with the actor to trigger the capture event. Need to see more of your code. How are you triggering capture?

Here is right after the points are given for capturing the area:

Holder team - determines which team captured. Red is false, blue is true
We get all teleports 1 (there is only one in the scene)
Next we set the ‘can teleport’. If red team captures we can teleport from teleport 1. If blue team captures we can’t teleport from teleport 1 (teleport 1 is inside red team’s base)
All of this works.

If blue team captures change the teleport material to blue. (I did not setup red team yet but will be the same once I get blue to work)
If I debug this, I can step all the way through with no issues. The material in the details panel changes to blue but the material on the teleport does not (this is shown in my first post)

The last thing is now I get teleport 2 and set weather or not we can teleport from teleport 2 to teleport 1 (this will be modified to go to teleport 3 also, which will be in blue’s base). This works correctly.

Since I still can’t figure this out, I decided to change the material instead of just the color. It does the same thing. It will change the material in the details panel but doesn’t update the game object in the scene.
This is a multiplayer game and I thought maybe it is an issue with that. So I added a server call but still have the same results.


I fixed the issue. Not sure why it happened. I found code that changed the color of the flag after capture that worked. I piggy backed off of that and it worked.

Nice. I’m in the process of building out a domination/conquest (battlefield) CP system. If you’re interested I can DM when it’s done. I’m setting it up with a single actor, server authoritative, DMI changes, configurable.

Drag-n-drop, configure, play.