Switch material on mouse click without box collision or widget

Hello!

I’m trying to do this and I’m not finding any related tutorials: I’m doing an interactive ArchViz just with the left mouse click. I have a line trace and what I want to do is to click on objects and change material. In my case the material is a video showing the design that rotates 360 ° so I have to connect also a media player.

I tried to do this with my little blueprint knowledge or by adapting tutorials to my case but it never worked.

The other unsolved problem related to this problem is this: https://answers.unrealengine.com/questions/1057459/media-player-doesnt-work-directly-on-mesh-material.html

I can’t play any videos on my mesh materials, only on planes and that’s a problem as that’s what I should do in this case since the material to be changed is on a mesh made in Blender.

I really hope someone knows how to do it and can help me. Thanks in advance!

This is how to play a vid on a mesh:

If you have the line trace, then you know which actor was clicked and can use a blueprint interface to tell it to change the mesh material.

It’s much easier to do that than trying to manage all the changes from the level blueprint.

Thank for the reply!

That’s the video I followed to learn how to start a media player but he use a plane and in this way works for me too. It doesn’t work if I want to set it on my mesh material.

My idea would be to create a blueprint for each interactive actor, not change the level blueprint - I don’t know if I’m wrong.

This is the blueprint I made and thought it worked but it didn’t:

UPADATE

Problem blackscreen solved, the solution is linked in my first comment - if someone need it. Now I just have to figure out what’s wrong with my blueprint…

To be able to change the material at runtime, in your actor blueprint you’ll want to create a dynamic material instance for each material on the mesh and promote them to a new variable. Using those variables you can then set the materials off of your event interact.

Let me know if this helps or you have any issues getting it setup.

Tutorial to help you out: Unreal Engine 4 - Dynamic Material - Tutorials Blueprints - YouTube

If using more than 1 material make sure each material gets promoted to a new variable (or added to an array)

Thanks for your help!

While doing some tests, I realized that it’s not a blueprint problem because if I copy-paste the same scripting to another mesh blueprint it works. I think that the problem is the dimensions: I’ve a very thin mesh and I suppose that the collision doesn’t work.

The question has changed: tips for creating an effective collision on this thin mesh? I think a complex collision is needed but I don’t know how to do it …

I’m thinking of opening a new thread as it would be off topic here.