How can I change material of actors between character and camera?

Hello. I’m trying to change object visibility between character and camera. For that I’m spawning line trace by channel from camera to character. When there is an actor between them I want to get it’s material and change the value of opacity in that material. But how to get that material? I don’t want to convert all meshes to blueprints like in that video: UE5 Tutorials : Control Material Parameters on the Blueprint - YouTube.

Try this:

My Products

No, even “print string” node doesn’t work.

It works for me, so you should debug your code. Print components, check collisions, etc.

Seems like the problem is in “Get material from Collision Face Index” node. Is it require primitive like cube, cilynder, etc from shapes panel?

image
The target is a primitive component.
It requires any primitive: static mesh component, skeletal mesh, procedural mesh, etc.

Well, suppose, I don’t quite understand what is primitive component. Is my wall should be an Actor (Blueprint)?

Your wall is a primitive component of some actor.

You can do it like this:

Or:

Fixed that. The problem was in “Trace Complex” setting of line tracer. Needed to toggle it on. But now cast to material instance dynamic is always failed.

Have you set the dynamic material instance to your meshes? Do The Materials have an Opacity scalar parameter?

  1. I don’t know. I’m just created material instance and applied it to mesh.
  2. Yes

Oh, I thought I can do it without convertion to actor. Finally, it’s work. Thank you very much!

Or:

1 Like

Thank you again. Works perfectly!