Change Material of a mesh with mouse click event in runtime with blueprint

Hi guys, I need to do something very specific and I don’t know how, so if you be so kind to help me, i will be very grateful.
I need a blueprint to assign to several actors (meshes) a property to change material with a mouse click over it. For example a Wood Wall change to a Concrete wall doing click over the mesh.
The second that I need for the same meshes is show a specific text in HUD when the mouse pass over the specific mesh, with “mouseover” property. At the same time, when the cursor (crosshair) is passing over the mesh, change the drawing of the crosshair for something like “finger” or “clickable”.
The meshes are six in total.

Thank you again, and I hope you can help me



Hi g0mo,

this should give you a great starting point

I created a variable click Id that will loop from 0 to 2. [0,1,2,0,1,2,0, etc], then I set a material on the current static mesh to the associated material created in the array.

Just be sure to set the correct material in your default variables


Thank you MarcAndreG, i will check and try to make it. Did you do it on Character Blueprint or in a new BluePrint?
If I have some new question i will ask you again :slight_smile:


Sure do not hesitate if you have any questions.

This was on a new blueprint assumed to be the blueprint on which you want to click and have the material change.

Thanks for your good willingness.

Ok, so I will follow your steps.

In the blueprint appears “Material 1” “Material 2”, etc. How do you add it in the blueprint?

what kind of action is the “Click id” and “Material” node?

This Blueprint works alone or with another?


If you’re not sure how to add variable to a blueprint, I think the first step would be to go watch a few tutorial to get the hang of it.

If you’ve never touched UE4 / blueprints, the Unreal has great tutorial series too that I’d recommend watching

Here’s one made by someone(aka not unreal) that seems to teach how to handle mouse click and touch events. It’s probably with a previous version of the engine but it still will get you some insight.


Hi MarcAndreG, I watched all the videos and now I understand the concept of variable and how can I create it, but I still having doubts about a lot of things.

The first thing that I’m trying to do is change the mouse cursor image (a custom image) when pass over a specific mesh. I know that I have to intervene 3 differents blueprint: Mouse_Controller, HUD and Mesh Blueprint (seeing how do I built my demo).

In the Mouse_Controller BluePrint I created two variables: “Mouse Pointer Image” (change the image of cursor) and “Shift Mesh” (variable that represent the mesh that makes the mouse’s cursor changes when it’s over it).

And two Events: “Begin Mouse Over” and “End Mouse Over”.

Basing on my low knowledge I think (in logical terms) would be like:

1.- Mouse pass over the mesh (Event happen)

2.- The Mouse Cursor change its image.

Following this, I connect “Begin Cursor Over” with “Set Mesh” with “Mouse Pointer Image”, but I receive an error: “Literal values are not allowed for array parameters”

I understand that I’m connecting nodes from different nature between them, but I don’t know how connect them or what conversor node have to use.

In HUD BluePrint, apparently everything its ok.

Well finaly i did this to make the material change. I post it if someone need to know how to do it. Is very simple.