SOVEREIGN MOON PRESENTS…
Bolt Introduction Tutorial For Absolute Beginners
In this tutorial we’ll teach you how to use Unity’s free Bolt add-on which will allow you to design video games without writing a line of code.
Learn How to Use Unity’s Bolt Add-On to Create Video Games Without Code
Today, Sovereign Moon Studios, the makers of your favorite NoCode game development course, are excited to bring you the first installment of our Bolt video tutorial series. In total, this three part video series consists of 30 minutes of video and will walk you through the basics of getting started with Bolt, Unity’s free visual scripting tool.
In this video we’ll introduce you to Bolt’s interface as well as break down the basic components of a Bolt unit (often called nodes in other programs). We’ll also talk about the difference between flow machines and state machines, what unit types are, how to properly connect unit ports and much more!
So if you’ve been thinking about learning Bolt, but you weren’t sure where to start, here is your chance.
Let’s jump in.
Introduction to Bolt & Visual Scripting
In this tutorial we’re going to learn how to use Bolt, which is a no-code visual scripting asset you can download for free from Unity’s asset store.
In a nutshell, Bolt allows you to design video games without having to write a line of code. You can use Bolt to do pretty anything you can dream up from controlling characters, designing combat AI, creating a game dialogue system or building a game inventory system. The possibilities are endless.
For example, look at the game I have in front of me now. I’ve designed this completely using no-code tools with Bolt handling the core of the game mechanics.
Bolt is a very powerful tool and there is a lot you can do with it. In fact, using bolt you’ll have access to 23,000 units which include the entire Unity scripting API. However, if you’re just getting started with Bolt and visual programming in general you’re probably looking for the most basic tutorial possible to help you get started.
So I’m going to begin by teaching you how to use Bolt to spin a game object. This will be as easy as it gets using Bolt. In this next tutorial in the series I’ll show you how I’m using Bolt to move game objects. In the last tutorial in the series, I’ll show you how to set up triggers using Bolt so you can do things like open doors, collect game items , turn on and off lights and much more.
Installing & Setting Up Bolt
Okay, so let’s begin by installing Bolt. To install Bolt for free, simply go into the asset store and search for Bolt. Go through the download and import steps. Once you have everything ready to go you need to click on “tools” and then “install Bolt”.
You’ll have to go through a short sequence of steps where you’ll need to do things like confirm your assembly options. You can simply keep all of the settings set to the default settings during this process and just click on “next” each step of the way.
When you’re on the naming scheme section, you’ll be asked if you want to use human naming or programmer naming. Unity shows you some examples of the two settings. You’ll notice that they are not very different.
However, I suggest using programmer naming because not only will it help introduce you to the world of programming, but it will also help make troubleshooting problems much easier.
Using programmer naming you’ll be more easily able to search things online and find solutions to any problems you’re having.
Optimizing Your Bolt Workflow
Next, with Bolt installed we’ll have three new windows we need to bring into Unity’s interface.
You can set these tabs anywhere you want, but here is my preferred placement. I like putting the graph inspector into its own section with variables and then I like to doc the graph tab beside the console tab down here. This is because your graphs can get big quickly and require a lot of space while your graph inspector and variables windows don’t require much space.
The Difference Between Flow Machines & State Machines
So let’s jump in by adding a Bolt component to an object. In my scene I’m going to add a cube. I can do this by going to “game object” and then “3d object” and then “cube”.
Now, with my cube selected I can add a new Bolt component to this object to get more control over how this object behaves in my game environment.
The possibilities for object control using Bolt are limitless. For example, we could set this cube object up so that when our character collides into it, we could add a cube item to our character’s inventory system. Alternatively colliding into this cube could trigger the opening of a door or the introduction of a cut scene. However, these are more complex setups and in this tutorial my goal is to keep your first task as simple as possible to help you build confidence using Bolt, so all we’re going to do is set up Bolt to help us spin this cube.
In order to do this we need to add a Bolt component to the object. After you’ve installed Bolt you’ll notice 2 new components that you can add to an object. For example, with my cube selected, if I click on “add component” I can search for “flow machine” or “state machine”. Both of these are Bolt related components.
More often than not, you’ll be using flow machines but let me explain the difference between flow machines and state machines to you now.
Essentially, flow machines explain HOW an object is supposed to behave, while state machines determine WHEN an object should change its behavior.
In order not speak in abstractions, let’s use this simple cube as an example. We want to determine how the object is behaving from the start (i.e default behavior). If we were just to drag this 3D cube into our scene and we played our game, we would have a static cube. But we don’t want it to be static, we want it to rotate. So we need to use a flow machine to set this up as the cube’s default behavior.
If however, our object would have different states, then we might need to use a state machine instead. For example, imagine we wanted this cube to follow our protagonist around if our protagonist came within a certain distance of the cube. Or imagine we wanted the cube to transition between 3 different states based on where our character was in the scene. For example, if the character was standing on a blue square the object might be motionless. If the player was standing on an orange square the object might bounce. And lastly, if the character was standing on a white square the object might rotate. These would all be different states.
So the state machine would help monitor when a state should be entered or exited. And the flow machines determine the changes within the object within each state. State machines can’t do much on their own. They need to have nested flow graphs within them which will determine their changes.
Some practical uses of state machines within games would include things like enemy AI. For example, you might want an enemy guard’s state to change from “guard” to “attack” based on your character’s distance to the guard.
Now when you add a flow machine or a state machine to an object, they don’t look very different at first glance. Notice the state machine’s default graph here and the flow machines default graph here. That’s because they use similar logic, they just are responsible for controlling different things.
So let’s jump in and add a new flow machine to our cube object.
When we add a new flow machine, all we need to do is add a new macro to our object. Now, this isn’t mandatory, but I suggest in order to stay organized, you create a dedicated folder within your game folder specifically for your macros. Here you can see I’ll be keeping my game macros in this folder.
So what we’ll do is we’ll keep the source set to macro and then we’ll click on this “new” button. Now we’ll be prompted where to save our macro. Once your macro is saved you’ll see your new flow machine component in your inspector tab.
Now, the first thing we can do is change the title and summary of our flow machine. This will have no impact on the game whatsoever, it will just help us stay organized. So let’s call this “rotating cube” and under description write “rotating cube example”.
When you’re done, you can click on “edit graph”. Now you’ll be brought to your graph editor where you’ll see by default Bolt has created two events for you. A “start” event and an “update” event.
Understanding Bolt Components: Unit Headers, Ports, Types and More
These default events are convenient but not necessary. You can always delete them by selecting them and hitting delete on your keyboard and you can re-add them easily if you need them by right clicking within your graph editor.
For example, I can delete this start event because I won’t need it for this flow graph. However, later if I decide I do need it I can right click within my flow graph and then a fuzzy finder will popup. If I don’t know where to look for this unit, I can simply search for “start” and it will show up. Or, if I know where this unit is, I can navigate there manually. In this case, I can click on “events’, “lifecycle events” and then select “start”.
But in this case I’m going to delete it again because I don’t need it because a start event will determine how you want an object to behave on start, where an “on update” event will determine how you want the object to behave for each frame of your game. So it will help you control events that are continuously updating. Since I want continuous rotation as a default object property, I’m going to be using the “update event” option.
Let’s Rotate our Object
Next, we’ll want to add rotation to our object. To do this, we’ll need to add a new unit. But which unit do we need to add? Well in this case, we can look in our inspector tab. Notice that rotation is part of an object’s transform setting. All objects need to have a transform component because at a minimum Unity need’s to know where to place the object within your game world and what its orientation and size should be.
Because the object’s rotation is the element we want to continuously update using our “update event” unit in our graph, we have a clue that we’ll need to search for the transform unit which you can see here.
So we can add a new unit in two ways.
We can either grab this trigger port and then drag a wire up to the right. When we let go a fuzzy finder will popup allowing us to search for new units.
However, we can also right click anywhere on the graph and click on “add unit” to bring up the fuzzy finder.
With the fuzzy finder open we can search for “transform rotate”. There are many different options that popup, but the one we want is this option which says “transoform.rotate: xAngle, yAngle, zAngle, relative to”.
Now, if you’re ever not sure what to use, you can roll over the option and view a description of what this unit is designed to do down here.
In this case, we can see that the unit does exactly what we want it to do, so let’s select it.
Bolt’s Graph Inspector Tab
This unit has now been added to our graph. If we select this unit, you’ll notice that in the graph inspector tab we can see more granular details about this unit. We can see the unit’s description as well as see the unit’s inputs and outputs.
When looking at a unit’s details in the graph, if you’re ever confused about what an input our output is, you can always select the unit and then read more about what the unit does in the graph inspector tab.
In this case for example, if we are unsure about what the yAngle input did, we could go over to the inspector tab and read more about it here.
In this case it says “degrees to rotate the game object around the Y axis”. So if we set this value to 1, the game engine would rotate our object 1 degree / frame. This would give us a nice slow continuous rotation. If we wanted a faster rotation would but in a larger number like 10.
Understanding Input & Output Types
Now notice here above the description, we also notice that each input and output have “types” associated with them. Understanding how “types” work in the world of programming is essential, and even though it’s less essential when you’re using no-code tools, I still believe it helps to have a basic understanding of what each type does.
Notice here in our rotation transform unit, beside our x, y and z angle, we have the type set to “float”. Float is simply a fancy way of saying “number”. So for example, we need to know that our Y angle needs to be a float (or number), because inserting a letter like “F” wouldn’t make any sense to this unit. For example, if we enter F, notice that the unit defaults us back to zero. This is because the input field isn’t looking for a letter, it’s looking for a number (or float).
There are many different “types” you can use, but here are some of the most common ones.
Float: is any number and may or may not contain decimals. For example 2 is float as is 2.876
Integer: is a round number such as 2,3,4 or 5
Boolean: a Boolean type is a “true or false” statement. For example, in Bolt, a “branch” is a very common unit that you’ll find yourself using a lot. Look at what happens when I right click and then add a unit and search for “branch”. If I add a branch and then select the branch unit and look in the inspector tab, you’ll see that this branch is described as a unit that is looking for a condition to be met and its type is set to “bool” which is short for Boolean. Booleans are common in game logic for many things. For example, the branch unit can help you see if an object is true or not. For example, a door could be closed unless the character has found the right key within the scene. So you could use a Boolean to create logic that if the key was found you could trigger “true” which would open the door. Or if the key wasn’t found, you could trigger “false”, which might pop up a message saying the character needs to find the key. So in a nutshell that’s booleans.
String: strings are another common type that you’ll use frequently. Again, “string” is just a fancy way of staying “a string of characters”. For example, the word “player” is a string as is “player_01”. For example, in Bolt I might want to add an object compare tag. Let’s search for this unit now. Once added, notice when I select the unit and look under its “tag” input, that input has “string” as its type. So for example, if we were looking to find an object within our game with the “player” tag, we could type in the string “player” here.
I’m telling you this, not because you need to know how branch units or compare tag units work in this beginner tutorial. These are more advanced units. I’m showing you this because having this programming language knowledge earling on will help you greatly down the line, both in understanding how units work as well as help you to troubleshoot issues when they arise.
So I hope this has helped you better understand the basic components of a unit and how to read the information you see on screen. But let’s delete these units and jump back into our task at hand. Let’s get this cube rotating. And to do this, we only need one update event and one transform rotate unit.
Now this unit in particular is nice and easy because we have these sections here called “inline values”. These sections allow us to make modifications right within the unit without having to connect any additional units. But not all units allow for inline values, so you’ll often need to connect multiple units to achieve the affect you want. But that’s getting a bit advanced, so let’s keep it simple for now.
So let’s make sure we’ve changed our Y angle to 1. Once we’ve made that change, we now need to wire up this flow graph. If you were to click anywhere on the graph outside of the units, you’d notice that our transform rotate unit is grayed out. This is because it’s currently not active. In order to activate it, we need to connect it to our “update” event. We do this by hooking in our update event’s trigger output into our transform unit’s “invoke” input. Both are represented by little green arrows, so it’s pretty easy to see how we make the connection.
The inputs and outputs you see on the left and right of a unit are called ports. We use ports to hook units together. In this case, we are going to left click on this output port and then drag our wire over into our transform’s input or invoke port. Once connected, you’ll notice the transform unit isn’t grayed out any longer which signals to us that it’s been connected properly.
Now, if we play our game, our cube object should be rotating. Notice in our case, it is! Also notice that when we are in game mode, we can see which units are triggering based on the trigger confirmations we’re seeing in our wired up elements below. Here for example, notice we can see the flow from our update event to our transform rotate unit.
Another nice thing about Bolt, is for the most part, the changes you make while in game mode will be saved when you exit game mode. For example, I can pause my game by hitting “CTRL, ALT, P” and then I can change the speed of our rotation and even add rotation to a new axis. Now, I can unpause the game and see the changes. But most importantly, once I exit game mode the changes I made are saved.
So that’ how you use Bolt to rotate a cube.
That’s all I have for you today. Thanks for stopping by our indie game development blog. If you’ve enjoyed this tutorial and you’d like to take your no-code game development skills to the next level, consider enrolling in our no-code game development course which you can learn more about by visiting our homepage.
Thanks for stopping by today.
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.