Introducing Bolt: Unity's new visual scripting tool | Unite Now 2020

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
♪ [MUSIC] ♪ [NARRATOR] Welcome to Unite Now where we bring Unity to you wherever you are. [ASHLEY] Hi, everybody. In today's Unite Now session, we're covering Bolt, Unity's brand new visual scripting tool. My name is Ashley Alicea, and I'm a Senior Developer Advocate for games at Unity. And throughout my years of working with game creator communities, I've often been asked about visual scripting, so I'm excited to cover this latest addition to the Unity family and share how it can empower game creators of all backgrounds. In case you missed it, Bolt was acquired by Unity earlier this year and is now officially included in all Unity plans at no extra cost. This means all of you can download Bolt today and start making games without having to write lines of code. That's because Bolt lets you use visual graphs instead of written scripts to create game logic. By adding and connecting nodes together, you can create interactions, events, sequences, and more for all sorts of games and apps. These node-based graphs are really handy for both non-programmers and programmers alike. You can use Bolt on its own, or in conjunction with regular scripts, whichever suits your work best. It supports every class and struct type, plus includes APIs for advanced tasks, custom nodes, and more. Now, there are many ways you can use Bolt. But here are some of the most common examples we see from folks using it today. Bolt is an excellent tool for rapid prototyping and testing. Say you're a game designer wanting to test out some logic for a game mechanic, or maybe you're an animator who wants to see how your work looks in-Editor. Instead of having to spend your time writing out potentially complex code or waiting for your team's programmers to make what you need, you can use Bolt to work more independently and quickly. This particularly comes in handy for events like hackathons or game jams. You'll get the most out of Bolt if you understand basic scripting and game logic, but if you don't have that experience yet, Bolt is an excellent place to start. Many use the tool as a way to understand C# concepts. Much of what you learn from it can be applied to regular scripting. Speaking of regular scripting, if you're a programmer who wants your code to be more accessible for designers, artists, or other non-programmers on your team, you can link bulk graphs to your existing scripts, create custom graph nodes, and lots more for better collaboration across disciplines. Bolt can also be used to create projects, graphs, or templates that you can share or sell to other users. For now, Bolt will remain as an Asset on the Unity Asset Store. You'll need to download and import it into your projects to use it. If you're using Unity 2018 or 2019, you can find, download, and import Bolt from the Asset Store directly within the Editor. If you're using Unity 2020, you can find it on the Asset Store via your web browser. Once you add it to your Assets, you'll be able to import it into projects as needed through Unity's Package Manager. Regardless of how you add it to your project, you'll have to run the Bolt Setup Wizard. This will take you through a series of setup options where you can determine the naming scheme, assemblies, and types used in your project. If you're new to Bolt and aren't an experienced programmer, use Human Naming and accept the default assemblies and types. Once you're set, click Generate to finalize Bolt setup. Now you're ready to create visual scripts. Now that we know how to get started, let's cover the basics of creating a simple game using Bolt. I'll review the core Bolt interface, features, and concepts as we create a simple Endless Runner game. At the end, I'll share some resources you can use on your journey to learn visual scripting, including the full project for what we're making in this session. Let's get started. There are several tabs you should open before getting started with Bolt. Once you have it installed, you'll find three new options for this under the Window menu: Graph, Graph Inspector, and Variables. Open all three and drag them to your preferred Editor layout position. Make sure to leave plenty of space for your Graph window. This is the main area where you'll view and edit your visual graphs. The Graph Inspector displays information about your Graph, and if you select the node, it will show contextual information about what that node does, and it's related inputs and outputs. The Variables tab contains all the variables you will create and use for your visual scripts. You can use this window to create variables for your current Graph, Object, Scene, application, or save data. For the sake of time, I already have my environment, character, and UI set up in my Scene view. The main Objects we'll be working with include our player character, PennyPixel, the Obstacle used for this EndlessRunner, an empty Game Manager Object we'll use as a container for some Graphs, and a Box Collider we'll use to trigger our game logic. We're now ready to create the first visual script for our Endless Runner game. There are several different ways you can approach creating a game like this, but I'll walk through a very basic example that shows many of the features Bolt has to offer. We'll start by adding a Machine Component to our Player GameObject. Machines are what execute the logic of your Graph when you enter Play Mode. There are two machine components that correspond to the two types of Graphs you can use: Flow Graphs and State Graphs. I'll cover the differences between them shortly, but for now, let's add a Flow Machine Component so we can use a Flow Graph. Adding a Machine to a GameObject will also automatically add a Variables Component. You'll need this to store any variables you want associated with your Object. Within the Machine Component, there's a drop-down option to choose the Graph's source: an Embed or Macro. In most cases, you'll want to use a Macro. These are much more efficient to use if your Graph will be reused across multiple Objects. An Embed is useful for when you need to use Scene references, but are intended for Graphs that will only be used once in the current Scene. Well keep this first Flow Graph as a Macro, and select New to create a new Graph Asset in our Project folder and apply it to our PennyPixel character. The building blocks of logic and events within a Graph are called Units. A new Flow Graph shows two Units by default: a Start and Update event. You can click and drag a Unit to move it around your Graph, and use the Graph Inspector window to learn more about it. Click anywhere in the background to deselect the Unit. You can add a title and description to each Graph you create, which won't affect functionality, but it will help you keep your project organized. You can select multiple Units at once by holding and dragging down the left mouse button, and you can erase them by pressing the Delete key. For our first bit of logic, we'll add a Jump mechanic to PennyPixel. Since she has a Rigidbody 2D component, we'll be able to apply logic that uses Physics. Specifically, let's update her velocity when we press the Space bar so she can jump into the air. Right-click anywhere on the Graph background to open the fuzzy finder, a searchable menu you can use to find and add Units to your Graph. You can click through the menu to find out what you need, or you can type it into the search bar. I'll search for the "Rigidbody 2D: Set Velocity Unit" and press Enter to add it to the Graph. We'll also add an "On Keyboard Input Event Unit" to detect when we press the Space bar. This Unit in particular is critical as Event Units are what activate the chain of events within your Graph. By connecting the green arrow ports of your Units together, you'll establish the order of execution your Graph requires to work. You can connect Units directly by clicking and dragging one port to another. In this case, we're dropping the Flow connection to an empty spot in the Graph to bring up the fuzzy finder and automatically connect to a Unit we want to add. Since the Set Velocity Unit requires and outputs a set of coordinates, we'll add a Vector 2 Create Unit to input new values into Set Velocity. Let's connect the Flow of these nodes together and test this in Play Mode. We can see Penny's default run animation begin. But if we press the Space bar, nothing happens, even though we can see how the Flow is moving through the Graph. That's because we need to apply values to the Units we're working with in order to see changes happen. The great thing about Bolt is that you can still edit Graphs in Play Mode. This is great for live testing and debugging, and you won't lose any Graph changes you've made when you leave Play Mode. Let's add two Units to get the horizontal value or X value of Penny's velocity. Get Velocity checks the current velocity of the indicated Object. By default, it's set to Self, which means it will reference Penny. Since we only want the X value of her velocity, we'll use a Vector 2 Get X Unit and connect its output to our Vector 2 Create Unit. This chain of Units will ensure that Penny's updated velocity will not move her horizontally across the screen. However, we do want her to move vertically, so let's make a variable to set a value that will apply to the Y value of her velocity. We only want this value to be applicable to the GameObject that represents Penny. Using the Variables window, we'll create an Object variable called JumpStrength. We'll use the Type menu to define what kind of variable we want to use. In this case, a Float number. Then we'll set the value we want it to have. Let's try "3". Click and drag your variable into the Graph window to use it. We'll connect JumpStrength to the Y value of our Vector 2. Then we'll take that combined Vector 2 output and apply it to our Set Velocity Unit. Cool, we can see Penny is now jumping when we press the Space bar. And if we increase the value a bit more, we can see how her jumps get higher. Since our Keyboard Input node is set to trigger when the Space bar is initially pressed down, I will change it to update when the Space bar is held down. This will change our logic so that Penny can stay in the air as long as we hold down that key. Now, let's apply her jump animation. I already have a simple Animator connected to Penny that will play her different Sprite animations based on two parameters. For her Jumping animation to be activated, we just need to set the Animator's boolean for jumping to true. We can do this in our Graph by adding an Animator Set Bool Unit and telling it to set the value for jumping to true. We can test this for ourselves and see that it's working. But we also need to add some Units to have Penny revert to her run animation when she's no longer jumping. This can be done with nodes we've already used. We can easily select, copy, and paste them into our Graph. We'll change the nodes to set the value of Jumping to false when the Space bar is let go. And now, Penny perfectly cycles through both animations. It's important to note that not all Bolt related changes will be saved during Play Mode. Any changes you make within your Graph will get saved. But if you create a variable or add components outside of the Graph window, those will get reset once you exit Play Mode. You can see the reference we made to the JumpStrength variable has remained in our Graph, but is no longer in our Variables window. We can simply re-add it now that we're out of Play Mode and our Graph will still work fine. Once you're done with your Graph, I highly suggest organizing it with Groups and Comments. You can create a new group by holding down Ctrl and your left mouse button and dragging a box around the nodes you want to group together. You can give each group its own titles and descriptions and even apply custom colors to clearly visualize your Graph structure. Now that our player character is set, I'll quickly set up a similar Graph to move the Endless Runner Obstacle. As with Penny, we're moving the Obstacle by setting its Velocity. But instead of having the Obstacle respond to a key press, we're using a Fixed Update Unit to keep the Obstacle moving over a fixed frame rate. An invisible Collider at the left edge of the screen serves as a trigger that resets the Obstacle's position once it's offscreen. By using a Random Range Unit with a Set Position Unit, we can randomize the height of the Obstacles during each reset to keep the game interesting. In Play Mode, we now have a continuous spawn of Obstacles for Penny to avoid, though nothing will happen if she collides with one. We also need to set up scoring so the player can get points for each Obstacle they clear. Before we do that, though, let's talk about one of Bolt's most super helpful features. When you're working on Graphs, you might find yourself setting up the same set of Units multiple times. Or you might end up with a large Graph that you want to reorganize and optimize. Both are great cases for using Super Units, a powerful nesting feature for parenting Flow Graphs. You can create a Super Unit just like a regular Unit by using the fuzzy finder. Alternatively, you can generate a Super Unit by dragging a separate Flow Graph into your current Graph. To illustrate how this works, I'm creating a small Super Unit to use for collision checks. It will advance the Graph's flow if a GameObject's tag matches a pre-defined string. In order to connect your Super Unit with regular Units, you'll need to add input and output nesting units and define what you want them to pass through the Super Unit. You can do this using the Graph Inspector. Control Inputs, and Outputs help direct flow, while Value Inputs and Outputs pass parameters of any type. I'll create a Control Input to pass Graph flow into the Super Unit, a Value Input for a Collider from a collision event, and a second value Input for a string to use for tag comparison. Since we only need to output Flow from the Super Unit, I've also defined a control Output on the Output Unit. Once we connect all the ports, we can jump back to our parent Graph and see our new custom Super Unit, which is now ready to use in whichever Graphs we'd like. In fact, let's go back to our Player Behavior Graph so we can use our new Super Unit again. This time, we'll use it to check if Penny has collided with a GameObject tagged as an obstacle. If she has, her damage animation will play, and she'll be removed from the Scene after a set number of seconds using a Destroy Unit. Again, small example, but as your games grow in size, you'll find that Super Units will save significant time and energy while you build out your Graphs. The approach I'm taking to creating scoring logic is a bit different than our previous Graphs. I want to update the score whenever an Obstacle resets its position. But I don't want to manage the player's score within the Obstacle itself. Instead, I'll add a Graph to my empty Game Manager Object, but I'll set it as an Embed. This means I can now use this Graph to reference other Objects in the Scene, like the Obstacle. I'll build out this Graph and use two Super Units this time: the one that we created earlier, and another that I had saved that handles updating the Scene's score variable. So far, this Graph will update the game score, but I want to see that change reflected in the game's UI. The text I have in my UI canvas is using TextMeshPro. But when I search for it using the fuzzy finder, no options for it appear. That's because TextMeshPro isn't included in Bolt's assemblies by default. We have to add it manually. However, it's easy to update your project's assemblies at any time, even after your initial assembly is set up when you install Bolt. Just go to Tools > Bolt > Setup Wizard. Follow the prompts and add the assembly you want to use with the + button at the bottom of the Assembly's tab. I'm adding TextMeshPro, and once my setup has been updated, I can now search for and see TextMeshPro options in the fuzzy finder. I'll add a Set Text Unit to update the score, and we can see it working when we enter Play Mode. For our last step, let's create a game over a sequence of events that get executed when the player collides with an Obstacle. This time, let's use a State Graph. We'll create a small example using a single State. Let's add a State Machine to our Game Manager Object and set the Graph as an Embed. These types of Graphs tell an Object how to behave when certain conditions or states are met. They either contain nested Flow Graphs called Flow States or can be Super States, which are nested State Graphs. Either can be Macro or Embed. And the States within a State Graph are connected with what we call Transitions. By default, the Graph will contain a Start State, but we'll replace it with an Any State. The Any State option can trigger Transitions to other States no matter what the current State of your game is. We'll then create and name a State to hold our game over behaviors. In order to trigger our Game Over State, we'll need to create a Transition between these two states, which you can do by right-clicking a State and selecting Make Transition. Within the Transition, you can add logic to determine what triggers it. In our case, we want our Game Over State to activate when Penny collides with an Obstacle. We'll add in Units just like our previous Flow Graph, then enter the Game Over State to add the behaviors for what will happen when the State is triggered. Using On Enter State, we'll add in Units that will destroy the Obstacle, change the score text to say "Game Over," and apply a red tint to the game's background. Let's return to Play Mode for one last test. Penny jumps, scores, takes damage, and now we have our Game Over State taking over to end the level. That's it. With just a handful of Units, we've created a basic Endless Runner game while learning the basics of Bolt. If you're ready to get started with your own Bolt-based games, we have several great resources to help you along your journey. First off, be sure to check out our Documentation, which covers helpful concepts, tips, and more for using Bolt. To see more examples of different games created with the feature, I highly recommend the BoltKits found on Unity's Asset Store. To use them, start a new Unity Project, download Bolt, and import the BoltKit you want to use. You'll be set up with a full template game that you can learn from or modify as you see fit. I've also created a set of additional Bolt examples that I'm sharing over on GitHub. And it includes the Endless Runner project we reviewed in this session. I'll be adding more projects to it over the coming months, so keep an eye out for future updates and send me some suggestions for examples you'd like to see. Lastly, come join our Q&A for this session on the Unity Forums. The Bolt team and I will be keeping an eye on it over the next week to answer any questions you may have after watching this presentation. We can't want to see what you all create with Bolt. Thank you so much for joining us today, and we hope you stay safe, healthy, and well. Happy game-making, and until next time. ♪ [MUSIC] ♪
Info
Channel: Unity
Views: 242,440
Rating: undefined out of 5
Keywords: Unity3d, Unity, Unity Technologies, Games, Game Development, Game Dev, Game Engine, bolt scripting, made with bolt, visual scripting, unity visual scripting
Id: DtbyC1OBpFg
Channel Id: undefined
Length: 20min 28sec (1228 seconds)
Published: Thu Aug 13 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.