[et_pb_section fb_built=”1″ _builder_version=”4.4.3″ background_image=”https://www.sovereignmoon.studio/wp-content/uploads/2020/07/moon.jpg”][et_pb_row column_structure=”3_5,2_5″ _builder_version=”4.4.3″ max_width=”1206px” max_width_tablet=”” max_width_phone=”” max_width_last_edited=”on|phone”][et_pb_column type=”3_5″ _builder_version=”4.4.3″][et_pb_text _builder_version=”4.4.3″ text_font=”Muli|300|||||||” text_text_color=”#e0d8c9″ text_font_size=”18px” text_line_height=”1.8em” header_font=”Abril Fatface||||||||” header_text_color=”#e0d8c9″ header_font_size=”42px” header_letter_spacing=”1px” header_line_height=”1.1em” header_3_font=”Raleway|200|||||||” header_3_text_color=”#e0d8c9″ header_3_font_size=”29px”]
SOVEREIGN MOON PRESENTS…
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.
[/et_pb_text][et_pb_button button_url=”#tutorial” button_text=”Read the Full Tutorial ?” _builder_version=”4.6.1″ custom_button=”on” button_text_size=”18px” button_text_color=”#353535″ button_bg_color=”#fff4af” button_border_width=”1px” button_border_color=”#d3d3d3″ button_letter_spacing=”1px” button_font=”Abril Fatface||||||||”][/et_pb_button][/et_pb_column][et_pb_column type=”2_5″ _builder_version=”4.4.3″][/et_pb_column][/et_pb_row][/et_pb_section][et_pb_section fb_built=”1″ custom_padding_last_edited=”on|phone” _builder_version=”4.4.3″ background_color=”#fcfcfc” module_alignment=”center” custom_margin=”||||false|false” custom_padding=”10px||10px||false|false” custom_padding_tablet=”” custom_padding_phone=”||||false|false” global_module=”1107″][et_pb_row column_structure=”1_5,3_5,1_5″ _builder_version=”4.4.3″ max_width=”998px” custom_margin=”|||150px|false|false” custom_margin_tablet=”” custom_margin_phone=”|||auto|false|false” custom_margin_last_edited=”on|phone”][et_pb_column type=”1_5″ _builder_version=”4.4.3″ custom_padding_tablet=”” custom_padding_phone=”|125px|||false|false” custom_padding_last_edited=”on|phone”][et_pb_image src=”https://www.sovereignmoon.studio/wp-content/uploads/2020/08/smlogo2.png” align=”center” src_tablet=”” src_phone=”” src_last_edited=”on|phone” align_tablet=”” align_phone=”left” align_last_edited=”on|phone” _builder_version=”4.4.3″ width=”100%” max_width=”48%” module_alignment=”right” custom_margin=”||||false|false” custom_margin_tablet=”” custom_margin_phone=”” custom_margin_last_edited=”on|phone” custom_padding=”|0px||0px|false|true” border_radii=”on|90px|90px|90px|90px”][/et_pb_image][/et_pb_column][et_pb_column type=”3_5″ _builder_version=”4.4.3″ custom_padding_tablet=”” custom_padding_phone=”||||false|false” custom_padding_last_edited=”on|phone”][et_pb_text _builder_version=”4.6.1″ text_font=”Muli|300|||||||” text_font_size=”17px”]
Sovereign Moon Studios is dedicated to helping game enthusiasts bring their creative visions to life. We are the publisher of the Web’s most loved NoCode game design course. Learn more here.
[/et_pb_text][/et_pb_column][et_pb_column type=”1_5″ _builder_version=”4.4.3″][/et_pb_column][/et_pb_row][/et_pb_section][et_pb_section fb_built=”1″ _builder_version=”4.4.3″ background_image=”https://www.sovereignmoon.studio/wp-content/uploads/2020/08/space-blog.png” background_size=”initial” background_position=”top_right” custom_margin=”5px||0px||false|false” custom_padding=”5px||0px||false|false” background_last_edited=”on|phone” background_enable_image_tablet=”off”][et_pb_row column_structure=”3_4,1_4″ _builder_version=”4.4.3″ custom_margin=”25px||||false|false” custom_padding=”5px||||false|false”][et_pb_column type=”3_4″ _builder_version=”4.4.3″][et_pb_text _builder_version=”4.6.5″ text_font=”Muli|300|||||||” text_font_size=”18px” text_line_height=”1.8em” header_font=”Abril Fatface|700|||||||” header_text_color=”#0a0001″ header_font_size=”42px” header_line_height=”1.4em” header_2_font=”Abril Fatface||||||||” header_2_font_size=”33px” header_2_letter_spacing=”1px” header_2_line_height=”1.1em” header_3_font=”Abril Fatface||||||||” header_3_text_color=”#565656″ header_3_font_size=”26px” header_3_line_height=”1.8em” hover_enabled=”0″ header_3_font_size_tablet=”” header_3_font_size_phone=”20px” header_3_font_size_last_edited=”on|phone” sticky_enabled=”0″]
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!
Introduction:
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.
[/et_pb_text][/et_pb_column][et_pb_column type=”1_4″ _builder_version=”4.4.3″][/et_pb_column][/et_pb_row][/et_pb_section][et_pb_section fb_built=”1″ _builder_version=”4.4.3″ background_image=”https://www.sovereignmoon.studio/wp-content/uploads/2020/08/space-blob2.png” background_size=”initial” background_position=”center_left” custom_margin=”0px||0px||false|false” custom_padding=”0px||0px||false|false”][et_pb_row column_structure=”3_4,1_4″ _builder_version=”4.4.3″ custom_margin=”0px||0px||false|false” custom_padding=”0px||0px||false|false”][et_pb_column type=”3_4″ _builder_version=”4.4.3″][et_pb_image src=”https://www.sovereignmoon.studio/wp-content/uploads/2020/09/counters-in-unity-3d-game-kit.jpg” alt=”counters in unity 3d game kit” title_text=”counters in unity 3d game kit” _builder_version=”4.6.1″ custom_margin=”0px||0px||false|false” custom_padding=”0px||0px||false|false” border_radii=”on|10px|10px|10px|10px”][/et_pb_image][et_pb_text _builder_version=”4.6.5″ text_font=”Muli|300|||||||” text_font_size=”18px” text_line_height=”1.8em” header_font=”Abril Fatface|700|||||||” header_text_color=”#0a0001″ header_font_size=”42px” header_2_font=”Abril Fatface||||||||” header_2_font_size=”33px” header_2_letter_spacing=”1px” header_2_line_height=”1.1em” header_3_font=”Abril Fatface||||||||” header_3_text_color=”#565656″ header_3_font_size=”26px” header_3_line_height=”1.8em” custom_padding=”35px||35px||false|false” hover_enabled=”0″ header_3_font_size_tablet=”” header_3_font_size_phone=”20px” header_3_font_size_last_edited=”on|phone” sticky_enabled=”0″]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.
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.
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.
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.
Conclusion
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. [/et_pb_text][/et_pb_column][et_pb_column type=”1_4″ _builder_version=”4.4.3″][/et_pb_column][/et_pb_row][/et_pb_section][et_pb_section fb_built=”1″ custom_padding_last_edited=”on|phone” _builder_version=”4.4.3″ background_color=”#fcfcfc” module_alignment=”center” custom_margin=”0px||0px||false|false” custom_padding=”||0px||false|false” custom_padding_tablet=”” custom_padding_phone=”||||false|false” global_module=”1106″][et_pb_row column_structure=”1_5,3_5,1_5″ _builder_version=”4.6.1″ max_width=”998px” custom_margin=”|||150px|false|false” custom_margin_tablet=”” custom_margin_phone=”|||auto|false|false” custom_margin_last_edited=”on|phone”][et_pb_column type=”1_5″ _builder_version=”4.4.3″ custom_padding_tablet=”” custom_padding_phone=”|125px|||false|false” custom_padding_last_edited=”on|phone”][et_pb_image src=”https://www.sovereignmoon.studio/wp-content/uploads/2020/08/smlogo2.png” align=”center” src_tablet=”” src_phone=”” src_last_edited=”on|phone” align_tablet=”” align_phone=”left” align_last_edited=”on|phone” _builder_version=”4.4.3″ width=”100%” max_width=”48%” module_alignment=”right” custom_margin=”||||false|false” custom_margin_tablet=”” custom_margin_phone=”” custom_margin_last_edited=”on|phone” custom_padding=”|0px||0px|false|true” border_radii=”on|90px|90px|90px|90px”][/et_pb_image][/et_pb_column][et_pb_column type=”3_5″ _builder_version=”4.4.3″ custom_padding_tablet=”” custom_padding_phone=”||||false|false” custom_padding_last_edited=”on|phone”][et_pb_text _builder_version=”4.6.1″ text_font=”Muli|300|||||||” text_font_size=”17px”]
Sovereign Moon Studios is dedicated to helping game enthusiasts bring their creative visions to life. We are the publisher of the Web’s most loved NoCode game development and design course. Learn more here.
[/et_pb_text][/et_pb_column][et_pb_column type=”1_5″ _builder_version=”4.4.3″][/et_pb_column][/et_pb_row][/et_pb_section][et_pb_section fb_built=”1″ _builder_version=”4.4.3″ background_color=”rgba(10,0,1,0.98)” global_module=”1039″ saved_tabs=”all”][et_pb_row column_structure=”1_2,1_2″ _builder_version=”4.4.3″ width=”84%” max_width=”1191px”][et_pb_column type=”1_2″ _builder_version=”4.4.3″][et_pb_text _builder_version=”4.6.1″ text_font=”Muli|300|||||||” text_text_color=”#e0dad2″ text_font_size=”18px” text_line_height=”1.8em” header_font=”Abril Fatface||||||||” header_text_color=”#e0d8c9″ header_font_size=”33px” header_line_height=”1.1em” custom_padding=”5px||||false|false”]
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.
[/et_pb_text][et_pb_button button_url=”/” button_text=”Learn More ?” _builder_version=”4.4.3″ custom_button=”on” button_text_size=”18px” button_text_color=”#fff4af” button_bg_color=”rgba(255,244,175,0)” button_border_width=”1px” button_border_color=”#fff4af” button_letter_spacing=”1px” button_font=”Abril Fatface||||||||”][/et_pb_button][/et_pb_column][et_pb_column type=”1_2″ _builder_version=”4.4.3″][et_pb_text _builder_version=”4.6.1″][/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]