Setting a material instance constant for a static mesh material causes warning in logs

On map load, I’m updating all the rocks placed on my map with a material instance constant, so I can update the material params (like snow/rain etc).

However (although this seems to work perfectly), when I call SetMaterial(someMaterial) on the static mesh component, I get this error in the log file.

[0036.41] DevPhysics: Error (1) in file ..\..\Physics\src\NpActor.cpp, line 227: Actor::setLinearDamping: Actor must be dynamic!

I’ve set “Can Become Dynamic” on the static meshes in the editor, but I still see this error.

Anyone know why it’s complaining and how I can fix this? Cheers

I remember getting a very similar error. My day-night cycle is faked with materials and I have to update all of the materials during gameplay. Everything worked fine, but apparently the engine didn’t like modifying material instances in a saved package. Ultimately, I decided to turn off the errors and warnings for that issue. I don’t think it was cluttering my logs, but it was appearing on my screen. I turned it off with the console command “DisableAllOnScreenWarnings” or something like that.

It seems that your issue is physics-related though. Do these messages belong to interactive foliage actors? Movers? If you really want to test it to see where the issue is, you might be able to start with a static mesh that doesn’t have any kind of physics or collision. But if the game works, you can probably just ignore the message.

I’m assuming your trying this on the static mesh. If I remember right you cant change the material to different material on static meshs during play. You can edit the material instance to change what’s on it already.

On the error. do you have a physic asset tied to the static mesh in code?

It seems that the error only occurs if I have a PhysicalMaterial set on the material.

I don’t have a physics asset for this mesh, I’m have just unchecked the “Use Simple Box Collision” etc in the mesh.

So as per my previous msg, I can avoid this error spamming the logs by making sure the phys mat is set to none before i assign it to the mesh, then afterwards assign it to the referenced mat inst.

This works, but seems a bit hacky. I’d love to know why this is actually happening.

Nathaniel3W](FPS Animations help - Character & Animation - Epic Developer Community Forums) what was the console command that turns off the on screen MIC Parameter has changed messages. I tried what you said above but it didn’t work. “console command “DisableAllOnScreenWarnings””


I would advise against modifying materials directly during gameplay. This can cause some anomalies as it is affecting the global material (hence why the warning shows).

Instead use CreateAndSetMaterialInstanceConstant() in StaticMeshComponent.

This creates a mat inst const, parents the material currently set and then sets it on the mesh.

what we are doing is turning off and on parameters to add in what we want. All the stuff is already added into the material then we just access the parameter from its material instance and set it to a 1 to turn it on and a 0 to turn it off.

@gamepainters Sorry. I knew it was something like that. I’m glad you figured it out.

That’s the right way to do it. But what if you want all the meshes with that material to change at the same time? Are you supposed to find all of those meshes, create new material instances for them, and then update all the material instances?

When I have updated during gameplay the material instance that’s saved in the package, the worst thing that has happened was I streamed a level and the material was wrong. I just re-update the materials every time I stream a level and I haven’t noticed anything else out of the ordinary.

What I found was, When we changed that particular material instances parameters. It changes all that textureS thru out the whole map, so it only needs called once. not over and over and over till they all ran. That why this code was added, so it would run one time that’s it.
if(CurMat != none)

if(GetFloat != 1)
CurMat.SetScalarParameterValue(‘Rain’, 1);

We have to do the same thing. Everytime the map changes the parameters must be set and updated to whatever your wanting to load or they stay the same in the next map.

Tip: Also when we are changing the textures looks on bsp with the parameter code, but I found to get bsp to change. Just add in any model under or outside the map(OUT OF PLAYING SIGHT) and add the bsp texture to that model, then you can get them to alter the bsp textures look. Like water running down walls.