Can I change a Material at runtime?

Hi!

I’d like to be able to change an Actors Material when I run over a Trigger.

I can change the material in the Construction Script with no problems, but when I change it during gameplay (when I run over the trigger) the Object just turns into the grey default material. I know how to adjust seperate values of a Dynamic Material at runtime, but I’d like to be able to change from an Opaque to an additive material for example.

Thanks for any help!!

You can find this question already answered here
https://answers.unrealengine.com/questions/24913/change-global-material-parameter.html

I disagree, that question does not answer the question made here.

The point is the interchange a material for another material completely different, not just change a bunch of parameters.

Is there a way to change a material at runtime? not just some parameter, but the full material.

Cheers.

Can you try disconnecting the “In Material” and in the parent of the “Create Dynamic Material Instance” node and than just manually set the material.

From what I can see your logic is sound, so it sounds like the “In Material” isn’t a valid material so the engine will grab the default material to use as your dynamic material.

Also just for debugging, make sure you put a “Print String” after the “Set Material” node just to ensure it is getting to that point.

Hey Juangea,

I believe you can do that just by “Set material” (for that you do not even need a dynamic material instance (unless you want to be able to change the parameters at runtime.
Best.