How to apply mesh material to an another mesh with onclicked-event?

Hello dear UE4 community,

I am stuck with a problem which I can’t fix for days even after hours of tutorials and google searching.
I tried to blueprint the material change, but it is not working and I have no idea why. In my head it should be pretty easy like - you click on a mesh -> with click apply its material to an another mesh, but in reality I got this and it’s not working:



What I’ve managed to do is to enable click actions and to get the cursor visible in the game mode.

I need to be able to click on the spray can mesh in the game mode and with the click the car material should get the same material as the spray can, but only in the first material slot (from green to red). I’ve imported the car mesh as a skeletal mesh, because it has animations for the doors, which I’ve made in 3ds max (missing car parts are intended). I also need the doors to be opened by a click on a static mesh by playing animation I made (but this is an another story). What you see on the screenshot with the blueprints is my really poor attempt to adjust some online tutorials and help from the forums to my project blueprints.

I’m not new to UE4 and I’ve watched tutorials, read documentation about the engine and also made some environmental design projects, but I seem not to understand the blueprint system on my own no matter how much I try and this is very frustrating for me.

If you have more questions, I am always here to answer them. Every little bit of information is a big help for me.

Thank you!

What is Spray_Button? If it’s the spray can thing in the level it won’t work because you can’t cast from it to the Z3. The Z3 is not a spray can so the cast will fail.

What you can do instead is Get all actors of Class (Z3_BP) on Begin Play and save it as a variable (right click result and promote to variable), then remove the Cast node and put the variable in the target instead.

If you want something more fancy you can get the color parameter in the material from the Hit Result (cast to the BP, get the material instance, then the color) and use that to set the color of the car directly.

Thank you for your fast reply and I am really sorry for, maybe, my stupidity, but I still can’t understand how to connect all the things properly.


I got the Z3 skeletal mesh promoted to variable (Ze), but I am not sure if I have to do it in spray mesh blueprint, level blueprint (which I am not allowed to use in this project) or in the Z3 blueprint.
Now I am more confused because I cannot connect the “hit actor” and my spray button mesh for the engine to know what the target of the click is.
Furthermore I also can’t connect the spray variable with the material asset from which a material should be picked from for the car material.

Why is it always so logical and easy in my head, but in reality…

Just promote it in the BP where you’re setting the material, you only need it for the Target there. You should Get Z3 instead of Set. For the Hit Actor you can cast to the spray can BP and get the material from there (drag from As spray can BP), get the mesh and then material, then hook that up to the material in Set Material by Name.

All right, I did everything as you said and got this warning:


So I’ve googled a bit and put an IsValid node as suggested in the forums which made the warning go away but the material still not applied to the car on click.
My Blueprint looks now like this:


The spray can also got a new parameter I guess?

You did this? “What you can do instead is Get all actors of Class (Z3_BP) on Begin Play and save it as a variable (right click result and promote to variable), then remove the Cast node and put the variable in the target instead.” If you did and still get the error put a Delay node with a tiny amount after Begin Play.

Thank you for your help, here is the solution in case other people will search for it: