# Switch material on mouse click without box collision or widget

**URL:** <https://forums.unrealengine.com/t/switch-material-on-mouse-click-without-box-collision-or-widget/491107>\
**Category:** Rendering\
**Tags:** Switch, line-trace, unreal-engine, mouse-click, question\
**Created:** [November 19, 2021, 8:04pm UTC](https://forums.unrealengine.com/t/switch-material-on-mouse-click-without-box-collision-or-widget/491107 "2021-11-19T20:04:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![srhrs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@srhrs](https://forums.unrealengine.com/u/srhrs)\
**Post date:** [November 19, 2021, 8:04pm UTC](https://forums.unrealengine.com/t/switch-material-on-mouse-click-without-box-collision-or-widget/491107/1 "2021-11-19T20:04:56Z")

</div>

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](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!

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 20, 2021, 9:32am UTC](https://forums.unrealengine.com/t/switch-material-on-mouse-click-without-box-collision-or-widget/491107/2 "2021-11-20T09:32:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![srhrs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@srhrs](https://forums.unrealengine.com/u/srhrs)\
**Post date:** [November 20, 2021, 11:58am UTC](https://forums.unrealengine.com/t/switch-material-on-mouse-click-without-box-collision-or-widget/491107/3 "2021-11-20T11:58:48Z")

</div>

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:

 ![352587-schermata-2021-11-20-alle-124815.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/7/3f75889f239b113cb91e6c32674f067c8ca5564c.jpeg)

---

<div class="post-metadata">

**Author:** ![srhrs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@srhrs](https://forums.unrealengine.com/u/srhrs)\
**Post date:** [November 20, 2021, 10:14pm UTC](https://forums.unrealengine.com/t/switch-material-on-mouse-click-without-box-collision-or-widget/491107/4 "2021-11-20T22:14:40Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Chasetopher](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chasetopher](https://forums.unrealengine.com/u/Chasetopher)\
**Post date:** [November 20, 2021, 11:00pm UTC](https://forums.unrealengine.com/t/switch-material-on-mouse-click-without-box-collision-or-widget/491107/5 "2021-11-20T23:00:04Z")

</div>

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](https://www.youtube.com/watch?v=P-J7ecGF1zk)

---

<div class="post-metadata">

**Author:** ![Chasetopher](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chasetopher](https://forums.unrealengine.com/u/Chasetopher)\
**Post date:** [November 20, 2021, 11:01pm UTC](https://forums.unrealengine.com/t/switch-material-on-mouse-click-without-box-collision-or-widget/491107/6 "2021-11-20T23:01:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![srhrs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@srhrs](https://forums.unrealengine.com/u/srhrs)\
**Post date:** [November 21, 2021, 1:29am UTC](https://forums.unrealengine.com/t/switch-material-on-mouse-click-without-box-collision-or-widget/491107/7 "2021-11-21T01:29:51Z")

</div>

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 …

 ![352617-schermata-2021-11-21-alle-021314.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/8/f/8f9ed8e434512a3df10c1920e23ebe7681e1288e.jpeg)

 ![352618-schermata-2021-11-21-alle-021323.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/f/ef68c9815c3efba1a1d1e185f58ca62ff9b95388.jpeg)

---

<div class="post-metadata">

**Author:** ![srhrs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@srhrs](https://forums.unrealengine.com/u/srhrs)\
**Post date:** [November 21, 2021, 5:53pm UTC](https://forums.unrealengine.com/t/switch-material-on-mouse-click-without-box-collision-or-widget/491107/8 "2021-11-21T17:53:25Z")

</div>

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