# Line trace an opacity mask

**URL:** <https://forums.unrealengine.com/t/line-trace-an-opacity-mask/397730>\
**Category:** Blueprint\
**Tags:** line-trace, opacity-mask, unreal-engine, Blueprint, question\
**Created:** [July 21, 2017, 3:54pm UTC](https://forums.unrealengine.com/t/line-trace-an-opacity-mask/397730 "2017-07-21T15:54:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kibblesticks](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kibblesticks](https://forums.unrealengine.com/u/Kibblesticks)\
**Post date:** [July 21, 2017, 3:54pm UTC](https://forums.unrealengine.com/t/line-trace-an-opacity-mask/397730/1 "2017-07-21T15:54:34Z")

</div>

Is there a way for a line trace to determine whether it’s hitting an opaque (white) or transparent (black) part of a masked material applied to a plane?  
I need it to hit the image in the centre of a plane, but ignore the transparent area surrounding it. Any thoughts?

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [July 21, 2017, 5:00pm UTC](https://forums.unrealengine.com/t/line-trace-an-opacity-mask/397730/2 "2017-07-21T17:00:13Z")

</div>

option 1. Add some collision primitive(s) (box or sphere) to this actor just on desired part, and detect line trace with it.

option 2. Model mesh that have the same shape as desired image, turn on per poly collision (use complex collision as simple) for it, place it over that mesh as hidden, and detect line trace with it.

---

<div class="post-metadata">

**Author:** ![Kibblesticks](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kibblesticks](https://forums.unrealengine.com/u/Kibblesticks)\
**Post date:** [July 22, 2017, 1:02pm UTC](https://forums.unrealengine.com/t/line-trace-an-opacity-mask/397730/3 "2017-07-22T13:02:48Z")

</div>

Thanks for the suggestions redbox, unfortunately I don’t know how big the images are going to be so I can’t create a coll box. Modelling is a work around but it’s an awful lot more work as we’ll be using this for tens, maybe hundreds of different shapes.

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [July 22, 2017, 5:30pm UTC](https://forums.unrealengine.com/t/line-trace-an-opacity-mask/397730/4 "2017-07-22T17:30:11Z")

</div>

UE3 had a feature called “Physical Material Mask”, that allows you to set black/white texture and apply 2 physical materials to surface. In UE4 its still in backlog, but maybe you can develop it on your own.

[https://docs.unrealengine.com/udk/Three/PhysicalMaterialMask.html](https://docs.unrealengine.com/udk/Three/PhysicalMaterialMask.html)

One more option is to detect color of hit surface by getting it from color buffer. So the invisible part of image will be filled with solid color, like (0.5,0.5,0.5), and you will ignore line trace when it hit.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![Kibblesticks](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kibblesticks](https://forums.unrealengine.com/u/Kibblesticks)\
**Post date:** [July 22, 2017, 7:39pm UTC](https://forums.unrealengine.com/t/line-trace-an-opacity-mask/397730/5 "2017-07-22T19:39:00Z")

</div>

Really interesting avenue to explore, thanks very much Redbox!
