# How do you select a static mesh element by clicking the left mouse button in the running mode?

**URL:** <https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222>\
**Category:** Asset Creation\
**Tags:** unreal-engine, hit, runtime, question\
**Created:** [January 22, 2018, 9:28am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222 "2018-01-22T09:28:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 22, 2018, 9:28am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/1 "2018-01-22T09:28:08Z")

</div>

How do you select a static mesh material element by clicking the left mouse button in the running mode?  
I want to click on the model to get the material element of clicks to change the texture.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 22, 2018, 9:45am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/2 "2018-01-22T09:45:39Z")

</div>

A bit confused here regarding whether you want to obtain the material or static mesh reference. The topic and description mention both. Generally you’d go about it like this:

- enable _Click Events_ in the controller
- ensure _Static Meshes_ have collision enabled (works fine with default settings)
- use Static Meshes’ _onClicked_ event to _Get/Set Material_

![227909-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/5/9/4596fca408adca75df5fff34ac0d13d2af5cb7e6.png)

Alternatively, you could trace from mouse position and project it to 3d world, check what you hit, change its material

And yet another way is to use the _GetHitResultUnderCursorForObjects_ node:

 ![227910-capture2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/7/7/277b0544862ae76b4f347900f70d7767394b5d50.png)

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 22, 2018, 11:21am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/3 "2018-01-22T11:21:50Z")

</div>

Thank you very much! But I want to get Element Index by clicking.

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 22, 2018, 11:30am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/4 "2018-01-22T11:30:57Z")

</div>

![227944-fb8d5ae37b86b842b87b4978c75e6be8.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/1/8/f181fbc10a0fa249c6c4ab4a906e58699c75d4e7.png)

This ground is a Mesh, But there are four kinds of materials, I want to click the corresponding position with the left mouse button, get the corresponding Material Element Index.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 22, 2018, 1:35pm UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/5 "2018-01-22T13:35:08Z")

</div>

> This ground is a Mesh, But there are  
> four kinds of materials, I want to  
> click the corresponding position with  
> the left mouse button, get the  
> corresponding Material Element Index.

Got it. I misunderstood you initially, my bad. You will need to use Complex Tracing (the tick box in the trace node) for this:

 ![227948-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/a/3/da334db8cf69442921b5a270795559a596ed05fe.png)

The last node up here will produce both - material slot index and the material slot name (_GetDisplayName_).

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 23, 2018, 1:39am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/6 "2018-01-23T01:39:45Z")

</div>

Always output only the contents of index 0.

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 23, 2018, 8:50am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/8 "2018-01-23T08:50:36Z")

</div>

This is my blueprint.

 ![228105-one.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/2/f/d2f8ee6f139b13013fa02f689a3f97db945fe95b.png)

But just print 0.

 ![228108-two.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/3/133bf96a15c58589b0446eecf0695c590d06e831.jpeg)

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 23, 2018, 9:01am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/9 "2018-01-23T09:01:44Z")

</div>

This is my blueprint.And I just want to identify the static object instead of the blueprint.

 ![228105-one.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/2/f/d2f8ee6f139b13013fa02f689a3f97db945fe95b.png)

But just print 0.

 ![228108-two.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/3/133bf96a15c58589b0446eecf0695c590d06e831.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 23, 2018, 9:09am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/10 "2018-01-23T09:09:37Z")

</div>

And that (pretty!) chair has more than 1 material element?

When you say:

> […] And I just want to identify the  
> static object instead of the  
> blueprint.

What do you mean by “_static object_”? Static mesh name?

Also, instead of the _SectionIndex_, could you try printing the _DisplayName_ of the _ReturnValue_ from the node _Get Material From Collision Face Index_?

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 23, 2018, 9:17am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/11 "2018-01-23T09:17:10Z")

</div>

Yes static mesh .

 ![228112-three.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/b/3/5b3dec4d7b2ada60296e6a364aa52c008213c18e.png)

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 23, 2018, 9:24am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/12 "2018-01-23T09:24:21Z")

</div>

Also,display name always print element 0 material name.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 23, 2018, 9:29am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/13 "2018-01-23T09:29:46Z")

</div>

Cool, so at least we’re can see the element 0 name. So we know the tracing is working.

Could you please test one more thing then? Could try printing the _Face Index_ directly from _Break Hit Result_ node and see what kind of numbers you’re getting there.

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 23, 2018, 9:40am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/14 "2018-01-23T09:40:00Z")

</div>

HAHA . face index always print -1…

![228113-timg-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/6/a/06af803822bb9b513d5be856117e8386cce5108a.jpeg)

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 23, 2018, 9:42am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/15 "2018-01-23T09:42:10Z")

</div>

What time is it now?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 23, 2018, 9:50am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/17 "2018-01-23T09:50:02Z")

</div>

I think I got it, open your mesh and enable per poly collision:

 ![228114-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/9/339597cf94efa33c28daa52bd85b19b0bed1636d.png)

Also, I just found out why my numbers where jumbled up initially. I mistook the LOD section for material index. There, I learnt something today.

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 23, 2018, 10:48am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/18 "2018-01-23T10:48:53Z")

</div>

Thank you for your patience.  
But still not.

 ![228119-aasss.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/7/4/174f7546baa729f8d5f01eadfd24c231025dd12b.png)

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 23, 2018, 10:57am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/19 "2018-01-23T10:57:14Z")

</div>

First of all,face index always print -1

 ![228120-sfsf.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/e/33e236a9205d2fc843114ef37d404fa7bd0bf299.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 23, 2018, 12:05pm UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/20 "2018-01-23T12:05:01Z")

</div>

Not sure. Perhaps you could explain how your actor is constructed:

![228131-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/e/5/ee5e73035e23cfb4a130a1550f75bc43caf6887f.png)

It seems to be more than just an actor with a static mesh component. Maybe you could test it with another actor. As simple a setup as it gets.

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 24, 2018, 1:45am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/21 "2018-01-24T01:45:25Z")

</div>

Can you send me your test file for reference?  
My Email is [576435459@qq.com](mailto:576435459@qq.com)

---

<div class="post-metadata">

**Author:** ![Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_0cb7be7ba4bc64b9dcbb8d10d6e603f5](https://forums.unrealengine.com/u/Anonymous_0cb7be7ba4bc64b9dcbb8d10d6e603f5)\
**Post date:** [January 24, 2018, 1:45am UTC](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222/22 "2018-01-24T01:45:44Z")

</div>

I’m really troubled.

[Next page](https://forums.unrealengine.com/t/how-do-you-select-a-static-mesh-element-by-clicking-the-left-mouse-button-in-the-running-mode/415222.md?page=2)
