Using Counters & Switches Within Unity’s 3D Game Kit

In this tutorial we’re going to learn how to use switches and counters to help us make our Unity 3D Game Kit video game more interesting.¬†

Sovereign Moon Studios is dedicated to helping game enthusiasts bring their creative visions to life by teaching them how to make a video game from scratch without having to know how to code or draw. ⚡

Learn how to use¬†Counters & Switches¬†Within Unity’s 3D Game Kit

Yesterday, Sovereign Moon Studios, the makers of your favorite NoCode game development course, taught you how to add dialogue boxes to your game. Today, we will continue our 3D game kit tutorial series by teaching you how to add counters and switches into your game.

Let’s jump in!


What we’re going to be doing in this tutorial is adding multiple switches into our game and then using those switches to open a small door once all of the switches are activated. This can help you improve your gameplay by forcing your characters to go on treasure hunts or fetch quests. Essentially, your characters will be prohibited from passing to the next level in your game until all of the items are found.

So let me show you how this works.

Begin By Adding Your Objects into Your Scene

To begin we need to add our switches and our counter into our game. All of these objects can be found under your project tab in your interactibles folder (which is contained within your prefabs folder). For this purpose of this demonstration we’re going to be adding the following into the scene

1. One small door (interactible)
2. Two switches (interactible)
3. One counter (interactible)

Once we’ve added those items into the scene, our game world will look something like this.

counters in unity 3d game kit
Next, what we need to do is we need to setup our counter. With the counter selected under the gameplay counter script we need to set the interaction type to open. We also need to select “is one shot” and change the “target count” from 3 to 2. The target count is simply the number we’re trying to count up to. In this example, because we’ve introduced 2 switches into the scene, our goal is for our character to activate 2 switches to activate the door opening. You will need to change this numbers based on the number of switches you’re planning on putting into your scene. For example, if you wanted to hide 5 switches within your scene, you would need to change this number to 5. However, because we’re only using 2 switches, we’ll keep this number set to 2.

After we’ve done this, we need to scroll down a bit and change our interaction type to “open” under the set game command script.

unity 3d game kit switches

Next, we need to select our switches so the switch inspector box opens up. We’ll do one at a time, but the changes we make to each one will be identical. With the first switch selected, change the interaction type from “activate” to “open”.

Next, you need to set the interactive object. To do this, simply go to your inspector tab and search for your counter. Your counter should be under your “gameplay” section in your hierarchy tab. When you find the counter, simply drag and drop it into the interactive object section of your switch.

Again, ensure that “one shot” is selected and ensure that layers is set to “player”.

Now, all you need to do is follow these exact same steps for your second switch. Simply select your second switch and copy the settings from your first switch.

unity switches

Now, within Unity you’ll notice that 3D Game Kit’s visual programing tools have drawn a white line between your switches and your counter. This helps show you that you’ve successfully made a connection between these objects.

Now We Need To Link the Counter to the Door

For the last step, all we need to do is link the counter to the door. To do this, select your counter from the scene tab or hierarchy window. Once the counter’s settings are visible in the inspector tab you’ll need to scroll down until you get to the send game command (script) section. Here, we’ve already set the interaction type to “open”, but we haven’t selected the interactive object yet.

In this example, we want the small door to open once both switches are activated, so let’s go over to our hierarchy section, search for our small door and then drag and drop that object into our interactive object section.

Unity - NoCode tutorial

Again, once we’ve completed this step, Unity will draw a white line between our counter and our door.

Let’s Play the Game and Test it Out

At this point, all of the steps are complete and our game should work. So hit play on your game and test it out. As you can see in my video tutorial above, when I activate one switch nothing happens. However, when I activate the second switch the door opens and my player can pass through.


In this tutorial we explored one thing that you can do with counters and switches. You can do a lot more with these tools then we cover in this tutorial. However, if you’re interested in this type of game logic, you might be interested in viewing a recent tutorial we published on how to use Bolt (a free visual scripting tool) to help you add more complex triggers to your game world. This will help you gain more granular control over your game’s mechanics.

Lastly remember, if you’re looking for more in-depth instructions on what you can do with counters, switches and triggers, then I highly suggest you enroll in our comprehensive no-code game development course. We go into much more detail in that course and we teach you how to take your no-code game development skills to the next level. Simply visit our homepage to learn more.

Sovereign Moon Studios is dedicated to helping game enthusiasts bring their creative visions to life without having to know how to code or draw. Our NoCode game development course teaches indie game devs how to build breathtaking games from scratch. ⚡

Want to Make Video Games?

Do you love game design? So do we! For this reason, we created a no-code video game development course that walks you through the process of bringing your game visions to life without needing to know how to program and without having to be an artist. We will teach you how to bring your game to life in our 4 hour 36 module no-code game development course.