Changing material by element index using LineTrace

Hello, I am wondering if it is possible to get the element index that is hit on the static mesh that is hit when using LineTraceByChannel.

I have attached my Blueprint so far, this let’s me change the material, but some of my meshes have multiple materials. Is it possible to retrieve and change the element index hit?

When you break a Hit Result you can get the Component and/or the Bone that has been hit, so you could use this to decide which material to change

Sorry My blueprint didn’t upload earlier. I am already using component, it changes the material but only for a specified element

hook the “Hit item” into the “Element Index”

I tried that earlier. I just tried again to make sure I wasn’t going mad. I get no change at all when I do this

Is there any way to do this? I have a map with multiple elements, each with their own materials, and want to have different events happen for each one on mouseover. Or would I have to actually have each part of the map as a separate mesh?

it will be easier in the blueprint, if you have all the materials at index 0. This is a shortcoming of the blueprint system, in that I have not found a way to determine “object types” (besides failing casts cascade trees, which seems laborious at best, and a simply a ton of overhead, that a simple query node would resolve).

The best thing I can think of, is to try to get the exact XYZ coord of the hit on the component your dealing with, have your own “map” on the side (by map I mean, that you know for the mesh, what each XYZ coord maps too in terms of the index for the component to change, of course “each xyz coord” could just be a simple polygon, where you check, is the hit location inside this poly?). This of course assumes you don’t wish to have each mesh only have one material, such that all materials are at index 0. But by going with all materials at index 0, the number of your static meshes, is going to skyrocket.

But if you do make the maps, then it’s a simple lookup, I have XYZ coord, which poly does it fall in, then just associate the appropriate index value for the material to change and off you go.

Hope this helps,

I don’t think it’s quite what I’m looking for. I have an actual 3d model of the map of the US, and each state has it’s own material. I would like to get what material/element of the mesh that was clicked on, similar to the OP. I’m doing this in C++ though; I thought maybe the ‘Item’ variable in the FHitResult might give me this according to it’s description, but it just returns -1. If this isn’t possible i’ll just have to make each state it’s own mesh I guess.

3d or Nd makes no difference, it has a surface and only one surface is going to be hit.

bottom line is this though, if each state is it’s own mesh, it’s going to be a lot simpler.

Yea I figured, I’ll just create an actor for the whole thing and organize that way and just get hit trace by component.