Get just overlapped actor

Hello,

I have mesh whose material can be changed. A widget open when player overlap the mesh. However, material of all meshes with that blueprint change. I just want to change overlapped mesh. I need to change “get all actors of class”. How can I do that?

Hi,

I am not sure if I got you right, but here’s what I would do in your case:

  1. Convert your mesh into Blueprint
  2. Place your color changing events inside your newly created blueprint
  3. use OnActorBeginOverlap event and check if overlapping actor is your player in question (otherwise it may register overlaps you don’t want to use)
  4. Call color changer from within OnActorBeginOverlap event

It’s unclear to me how exactly you want to change your mesh (so far you called only “red change”), so if you need more help, please ask. :slight_smile: Also note that you can supply a parameter to your event so you can have one OnColorChange and then switch to assign different materials there.

I’m already can change the material but when I change one mesh, all other meshes change with that blueprint so I need to create different UI and blueprint for all the meshes or materials. However, I don’t think this is the proper way.

And which part of my answer doesn’t work for your use case, if I may ask?

I think I don’t understand your answer :slight_smile: I can change the material as in your answer. However, for example I have two different mesh. I need to create two different blueprint for them which I don’t want :))

Without concrete details it’s impossible to tell what and how you really want to achieve your goals. But you can have for example one single blueprint with static mesh component and you can create child blueprints with your meshes or you can even set those meshes dynamically, Both boiling down to have just one Blueprint actually taking care of a color change and collision.

You can change then the color of the attached mesh component in one spot.

If you want more help, you should post also more details about your BPBoxColour class (which already is a blueprint anyway).

If you for some reason don’t want to handle your collision in the blueprint but rather in your playable character, you need to intercept once again OnActorBeginOverlap but this time in your character class. There you need to check if your overlapped actor is of the class BPBoxColour by using Cast To BPBoxColour and if successfull, you simply call your color change on it.

If you need, I can make you some BP screenshots how both variants would look.