# Is it possible to set visibility of a single instance of an instanced static mesh component?

**URL:** <https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883>\
**Category:** Rendering\
**Tags:** visibility, unreal-engine, Instanced-Mesh, question\
**Created:** [January 22, 2016, 1:59am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883 "2016-01-22T01:59:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![thecomediclife](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thecomediclife](https://forums.unrealengine.com/u/thecomediclife)\
**Post date:** [January 22, 2016, 1:59am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/1 "2016-01-22T01:59:16Z")

</div>

So I currently have an angled “top down” game where occasionally, I might have an object or two in between the camera and the player. Seeing as how this might be problematic sometimes, I did something similar to [this](https://answers.unrealengine.com/questions/21065/making-an-actor-invisible-to-the-camera-only.html) to set individual components visibility when they block the view.  
However, for performance reasons, I’m using “instanced static meshes” and when a single component’s visibility is set, all instanced mesh’s visibilty are also set.

Is there a way to set the visibility of a single instance of an instanced static mesh component?

---

<div class="post-metadata">

**Author:** ![DamirH](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/damirh/32/906591_2.png) [@DamirH](https://forums.unrealengine.com/u/DamirH)\
**Post date:** [January 22, 2016, 2:13am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/2 "2016-01-22T02:13:36Z")

</div>

Instanced Static Meshes are basically one single big mesh so unfortunately no. What I personally did was create a material that turns transparent (Masked material + DitherTemporalAA) when it “intersects” the camera vector.

---

<div class="post-metadata">

**Author:** ![thecomediclife](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thecomediclife](https://forums.unrealengine.com/u/thecomediclife)\
**Post date:** [January 22, 2016, 2:15am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/3 "2016-01-22T02:15:55Z")

</div>

Could you elaborate a little for me? Would it then be possible to set the material of a single instance in an instanced mesh? I’ve considered this idea, but I couldn’t figure it out.

---

<div class="post-metadata">

**Author:** ![DamirH](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/damirh/32/906591_2.png) [@DamirH](https://forums.unrealengine.com/u/DamirH)\
**Post date:** [January 22, 2016, 2:20am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/4 "2016-01-22T02:20:52Z")

</div>

The material is one and the same, but since it takes the camera position and direction to create a “cylinder” mask, only the instances actually close to the camera would be affected. Thing is though it’s done PER-PIXEL, not PER-INSTANCE. Ends up looking good enough though.

---

<div class="post-metadata">

**Author:** ![thecomediclife](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thecomediclife](https://forums.unrealengine.com/u/thecomediclife)\
**Post date:** [January 22, 2016, 2:22am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/5 "2016-01-22T02:22:57Z")

</div>

That sounds amazing. I’ve never heard of such a thing. Do you have any link where I can read up on how to do this myself or watch a tutorial on how to do this? I’d google it myself, but I’m not sure what to even search for, considering I’ve never heard of this before.

---

<div class="post-metadata">

**Author:** ![DamirH](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/damirh/32/906591_2.png) [@DamirH](https://forums.unrealengine.com/u/DamirH)\
**Post date:** [January 22, 2016, 2:41am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/6 "2016-01-22T02:41:55Z")

</div>

Unfortunately it’s all home-made and not public. ☹ But it’s really not difficult to do. Look up some math on point-to-line distance, where your point is your Absolute World Location and the line is the camera vector. If the distance is below a certain threshold, you set opacity mask accordingly.

---

<div class="post-metadata">

**Author:** ![jman2015](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jman2015](https://forums.unrealengine.com/u/jman2015)\
**Post date:** [March 11, 2016, 2:22am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/7 "2016-03-11T02:22:39Z")

</div>

Not sure if this is still an issue. But this is now possible. Take a look at my blueprint below to check it out. You can also set a different mesh all together in a place in the mesh. I set LoctionX to 0 to start with and PannelSize I have set at 245 but that can be configured to match a mesh of your choosing.

 ![81730-part1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/d/2/2d2e3728fa0c408e67d4af80634c4b37435b8b48.png)

 ![81741-part2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/c/0/fc0c42436b15cbd6a2802d474dcc2586cb7018e7.png)

 ![81742-part3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/7/2/b72b4f3f0611a76a2c01c68ef91e7912ce0dc141.png)

 ![81743-viewport.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/c/e/dce372e8372f2e80dec4197be546450313b569ce.png)

---

<div class="post-metadata">

**Author:** ![TheSpaceMan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheSpaceMan](https://forums.unrealengine.com/u/TheSpaceMan)\
**Post date:** [March 17, 2016, 7:07pm UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/8 "2016-03-17T19:07:44Z")

</div>

This is an old one, but just set the scale of that instance to zero. easiest way to make it not render without needing to change materials and what not.

---

<div class="post-metadata">

**Author:** ![Zirrad](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zirrad](https://forums.unrealengine.com/u/Zirrad)\
**Post date:** [April 27, 2016, 8:17pm UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/9 "2016-04-27T20:17:00Z")

</div>

That’s what I tried, but unfortunately it’s not working how I hoped it would work.

As you have it set up, you’ve created multiple “instancedStaticMeshComponents” each with only one attached instance.  
(and there’s a limit of the # of instances you can have, something like 10 - check the output log)

As far as I understand, every instance shares the properties of the render component. So you need one instanced component for each group of similar looking meshes.

The transform seems to work on each instance, so perhaps the “scale to 0” approach might work to make one instance invisible

---

<div class="post-metadata">

**Author:** ![loh0123](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@loh0123](https://forums.unrealengine.com/u/loh0123)\
**Post date:** [July 28, 2017, 9:48am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/10 "2017-07-28T09:48:45Z")

</div>

nice ideal

---

<div class="post-metadata">

**Author:** ![Nightmask3](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nightmask3/32/894376_2.png) [@Nightmask3](https://forums.unrealengine.com/u/Nightmask3)\
**Post date:** [September 26, 2017, 12:40am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/11 "2017-09-26T00:40:45Z")

</div>

this is a really neat idea and something I’m going to use, thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_44738cd7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_44738cd7](https://forums.unrealengine.com/u/anonymous_user_44738cd7)\
**Post date:** [August 21, 2018, 9:36pm UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/12 "2018-08-21T21:36:41Z")

</div>

Very good tip, thanks a million man, you saved me a lot of code!

---

<div class="post-metadata">

**Author:** ![danielcwr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@danielcwr](https://forums.unrealengine.com/u/danielcwr)\
**Post date:** [June 5, 2021, 9:16am UTC](https://forums.unrealengine.com/t/is-it-possible-to-set-visibility-of-a-single-instance-of-an-instanced-static-mesh-component/344883/13 "2021-06-05T09:16:20Z")

</div>

Setting the scale to 0 is great, but I found that an unintended side effect was that the instance’s rotation was lost in the process somehow. (Example: Setting rotation to 0, then back to 1, caused the rotation to be reset to default. This does not happen when I set the scale to 0.1 instead.) The solution is to store the rotation somewhere before you set the scale to 0.

See here for details on how this is intended: [https://answers.unrealengine.com/questions/158576/update-instance-transform-sets-rotation-to-000.html](https://answers.unrealengine.com/questions/158576/update-instance-transform-sets-rotation-to-000.html)
