Can I use a raycast to get information about an actor's material?

Hello! I have a question about raycasts and materials. I have a sort of fog of war, and I want to make it so that characters in my game can’t leave the uncovered area of the map. The fog of war is really just a plane with a material on it. I’m trying to use a raycast to find the opacity of the material on that plane at the hit point, but I keep hitting brick walls. Is there a way to find the opacity of the material using blueprints?

Sure, a trace can return the material hit. It’s in the HitInfo. Then once you find that, you should be able to find the material instance parameters.

This doesn’t sound like the right way to go about disallowing movement, though. I’d presume that the fog plane is something that is just visible to the player, and not actually an object with collision in the world. Are you trying to trace from the player? or… ?

I took a look at that material hit in the hit info, but it doesn’t allow me to actually get the texture from it. I can sort of access the material in a roundabout way using the Hit Actor result, but that hasn’t worked for me yet either.
Yes, the fog plane is just visible to the player. At the moment, it does nothing except for obstruct the player’s view of the parts of the map that aren’t around the player’s area of control. Nothing can collide with it, except for the raycast. Also, yes, the raycast is being cast upward from the player.

In the material set Opacity as a Parameter.

Line trace hit mesh → Break result → get mesh component → get material → get parameter info.

1 Like