# How do I count how many instances of a class have the visibility of a light component toggled on?

**URL:** <https://forums.unrealengine.com/t/how-do-i-count-how-many-instances-of-a-class-have-the-visibility-of-a-light-component-toggled-on/477067>\
**Category:** Rendering\
**Tags:** toggle, light, unreal-engine, question\
**Created:** [January 11, 2021, 2:03am UTC](https://forums.unrealengine.com/t/how-do-i-count-how-many-instances-of-a-class-have-the-visibility-of-a-light-component-toggled-on/477067 "2021-01-11T02:03:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_d892426d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d892426d](https://forums.unrealengine.com/u/anonymous_user_d892426d)\
**Post date:** [January 11, 2021, 2:03am UTC](https://forums.unrealengine.com/t/how-do-i-count-how-many-instances-of-a-class-have-the-visibility-of-a-light-component-toggled-on/477067/1 "2021-01-11T02:03:34Z")

</div>

The goal of the game is to turn on all of the lights of a certain kind and turn off the lights of another. I have it so that you can toggle visibility for these kinds of lights. The blue and red lights are separate classes. How do I count how many instances of the blue lights have the spotlight toggled on and how many instances of the red lights have the spotlight toggled off?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d892426d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d892426d](https://forums.unrealengine.com/u/anonymous_user_d892426d)\
**Post date:** [January 11, 2021, 2:11am UTC](https://forums.unrealengine.com/t/how-do-i-count-how-many-instances-of-a-class-have-the-visibility-of-a-light-component-toggled-on/477067/2 "2021-01-11T02:11:27Z")

</div>

By the way, this is how the blueprint looks

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 11, 2021, 8:37am UTC](https://forums.unrealengine.com/t/how-do-i-count-how-many-instances-of-a-class-have-the-visibility-of-a-light-component-toggled-on/477067/3 "2021-01-11T08:37:44Z")

</div>

You can do it like this:

 ![326931-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/4/e/e4ea81224292caf618f2b16f0db2db06251aba7d.jpeg)

You’ll find it easier if you do all the light as one blueprint and make the color a parameter 🙂

( Otherwise you’ll need to write another custom event to count each color )

 ![326932-screenshot-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/5/1/b51326a0e57de8155c1ba84d6614e87ae905adf3.jpeg)

 ![326933-screenshot-3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/5/5/b55dea52f6f5da082f34e038ce797f4a7cf663cc.jpeg)
