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.
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
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:
Thank you very much! But I want to get Element Index by clicking.
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.
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:
The last node up here will produce both - material slot index and the material slot name (GetDisplayName).
Always output only the contents of index 0.
This is my blueprint.And I just want to identify the static object instead of the blueprint.
But just print 0.
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?
Also,display name always print element 0 material name.
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.
HAHA . face index always print -1β¦
What time is it now?
I think I got it, open your mesh and enable per poly collision:
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.
Not sure. Perhaps you could explain how your actor is constructed:
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.
Can you send me your test file for reference?
My Email is 576435459@qq.com
Iβm really troubled.