Make games without Code? Visual Scripting! (Unity, Bolt)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we're going to get started using bolt which is unity's official visual scripting tool it is very visual and very simple to use while also being immensely powerful you can use it to make complete games or use it as a learning tool to help you learn programming let's begin [Music] hello and welcome i'm your code monkey and this channel is all about helping you learn how to make your own games with in-depth tutorials made by a professional indie game developer so if you find the video helpful consider subscribing all right so here we're going to learn how to do visual scripting in unity using bolt is already a very robust visual scripting tool it has been development for several years now and unity bought them a while ago now since unity bought the tool they have made it completely free for anyone to use if you're coming across this video while being completely new to unity check the link in the description where i cover the unity basics in a quick video here i will assume you know what are transforms game objects components and so on okay so bolt is extremely easy to install in get started first you go to the asset store and just search for bond and you'll find it it's completely free so just add to your assets and then click the button to open in unity when you do it opens up the package manager and down here you can see a button to download so click on that and then click on import so right away this only imports a few files and as soon as it's done go up here into tools and click on install bolt so it asks you a question and just click on import and yep now it imports all the actual files if you want you can go ahead and just delete the install bone folder alright so we see our very nice wizard tool let's go ahead hit next and now here it asks you a very interesting question so do you want human naming or programmer naming now this is a really interesting question because it depends on what your goals are with visual scripting one of them will show you nodes and actions pretty much just as standard english so for example it says list of game object whereas the other one will still work as visual scripting but won't show the nodes just like the underlying c-sharp syntax so it shows exactly as you would write code to a list of type game object so if you have no concept of programming syntax at all it might seem like human naming is the way to go however i would strongly encourage you to go with programmer naming now the reason is because even if you have no interest in learning written c-sharp programming it is still a huge help to know the absolute basics it will help you communicate with programmers and easily find solutions for any problem you have and by just using programmer naming you won't be exposing yourself to basic programming syntax so even if you're not intentionally trying to learn c-sharp you will learn it as you use visual scripting more and more but at the same time just like it says down here you can change this at any time so if you feel intimidated by programming syntax you can start off with human naming and then later on transition into programmer name okay so in this case i won't be choosing programmer naming then here we see some assembly options this is for more advanced users in case you want to load external libraries in our case we want to keep it simple so just leave it all at the default and click next then we have a list of types again it's for more advanced use cases where you want to add your own custom types as nodes so for now leave everything at default and just hit on generate all right so after a bit everything is generated and we have bolt fully installed and ready to be used awesome let's hit close and yep let's start actually using it let's try making the most basic example possible in unity which is to make just the cube spin around so first let's create a cube so again just a basic 3d object all right there's a basic cube in our scene and now to make a visual script we can go up here to click on add component then we go under bolt and in here we're going to add a flow machine okay so right away we see some options we see a field for a macro the macro is around the script so go ahead and click on new and just save the macro anywhere in this case let's call it our spinning cube all right there it is and now we can also add a title in summary if you want so let's just say all right so there's our macro now let's click on edit graph and yep right away the graph window pops up so we can already see the default state of our graph we have a stern event which is fired just once at the beginning and then update event which is fired on every single frame so this is the graph window where we're actually going to draw our graph and there's another window related to both that's also very useful so go up here into window and we're going to open the graph inspector this one works basically the same as the normal inspector except it's for when you select nodes inside of the graph so for example selecting the update node and over here i can see yep there you go update is called on every frame so let's dock it right next to the graph just like that all right so here's our basic layout we have the graph and graph inspector okay now let's remember what's our goal here the goal is to spin our cue so what that really means is to rotate it on every frame so let's start off by getting rid of the start event since we don't need it and now we can go up here to our update event and click and drag out this arrow and as soon as we drop it yep there you go it shows a menu with all the actions that we can take from this input so if you want you can browse around this list to see all the nodes that are available so for example over here you see a whole ton of math functions then here we can access some collections and under code base we can access pretty much anything so as you can see there's tons of nodes to do exactly anything you want to do now since there's so many of them the better approach is simply to use the search bar now we want to rotate so let's just type in rotate as soon as you do we see a whole bunch of rotate methods now in this case what we want to do is rotate our transform so it's going to be one of these and we can see that they take different types of parameters let's just select the simplest one which is this one here which just takes three floats so click on it and there you go there's our transform rotate node and here in the graph inspector we can also visualize all the inputs and outputs so the first input is the flow so it goes from event into there then we have the target which is going to be this object and then we have three floats and for the outputs we just have an output flow all right so in this case let's just rotate it on the y axis so over here let's just hit one and yep that's it this is all it takes this will add one to the object y angle on every single update so just like this let's test and yep there you go we have our very nice spin eq awesome now one really cool thing about bolt is how you can visualize the flow inside a graph so we can see that the update event is constantly being fired and is being received by the rotate node so this becomes an extremely small feature as your scripts become more and more complex okay so this is the most basic graph now when it comes to scripting one very important element are variables so let's look at that so for the variables there's another window we can open so again go into window and open up variables all right so here we can see tons of variables that we can use in our scripts let's dock it right next to the flow graph so right underneath the graph inspector yep there you go and now here just a quick unity tip you can make the active window full screen by clicking on the window and then hitting on shift and space and there you go just like this it makes the current window full screen alternatively you can also click on this full screen button so it goes from that to that or just double click on the window itself and on these buttons here you can switch these from left side to the right side personally i prefer on the right side so here we have a bigger area to work with ok so to make a variable it's actually very simple down here on the graph variables we can click on here in order to input a variable name in this case let's call it our speed variable and click on the plus icon and over here we need the type now for our speed we want it to be a float so yep select float and then some default value so in this case let's set it to something like three all right so that's it that's our variable all set up now we just click in this position right here and then drag it into our graph and there you go here we have our get variable node so from this port out here we get whatever value is stored in the variable so we just take this one and connect it onto the y angle and if there you go now it's going to rotate our cube based on the speed that we set in the variable all right so let's test and if there's a cube now spinning faster and again volt is awesome and shows us the flow of values that are going into the inputs and outputs so we can see that over here we have a 3 being sent from this variable onto this input and if you modify the variable in here instead of three and let's say nine and yep there you go it automatically updates so even while the game is running you can easily modify the code right awesome now let's try doing another basic thing let's listen to some input and make our cube jump now in order to make it jump let's add some physics so for that just over here on our normal cube game object let's add a rigid body component yep there you go just like that and let's also make a floor so it doesn't fall into infinity so just create a new plane alright so here we have our cube it's rotating and falling along with gravity now here in our graph let's expand it and now let's right click and we're going to add something let's search for add force and we're going to apply some force to our rigid body so let's go with this one that takes three floats and then the mode okay now here we want to jump up so let's add some value on the y and for the mode let's select impulse since it's meant to be instantly applied okay so here's what we want to do just add some force on the y all right now we want to trigger this on a key press so let's right click and we're going to search for get key down if there you go input get key down so once again you can look in the graph inspector to see what it actually does so it returns true during the frame when the user starts pressing the key down and then here for the key let's select the space key and now we have our two outputs one of them is the simple flow and the other one is the boolean so this volume will be true when we press the space bar and we only want to run this rigid body when that one is true so now the question is how do we connect these two nodes since we can't directly link the volume in there and now what we do is let's drag the bowline and right away we see our little selector and let's select our branch so this branch node takes an input it takes a flow and then we have the output which are two flows one of them if it's true and one if it's false so if it's true then we want to run and actually add force to our rigid body and we also need to connect the flow to the branch input okay so that's set up however you can see that these nodes are slightly transparent that means they're not being used at all now one key concept in programming and running code is the flow of execution essentially the code runs line by line so it runs the first line the next line and so on here we can visualize that same process with the flow of execution so we start off on the update then we go and we execute the rotate node and then after that we need to connect this into the get key down which will then run this one then run this one and run this one essentially there always needs to be a continuous flow from start to finish and right now you can see they're normally transparent since they are indeed being used alright so here's our complete script the cube will always be rotating based on the speed set in the variable and then if we press the space bar it will add force on the rigid body and make it jump up okay so let's test here's our spinning cube and down here on the graph we can see exactly what it's doing so the flow is constantly running but yep there's no following here since it only runs when this one is true so now if i press on the space key if there you go the cube jumps up and you can see that one become activated for exactly one frame so since i press if there you go you add some force and he moves it upwards all right so here we have a very simple script fully working all right awesome okay so this was the complete basics to getting started with bolt and now that the basics have been covered i want to ask you what would you like to see would you like to see more visual scripting content if so exactly what type maybe some complete games maybe some bolt compared with c sharp maybe converting some of my previous mate systems to be made with bond let me know in the comments what you'd like to see if you found this video helpful consider liking and subscribing this video is made possible thanks to these awesome supporters go to patreon.com unitycodemonkey to get some perks and help keep the videos free for everyone as always you can download the project files and utilities from unitycodemonkey.com subscribe to the channel for more unt tutorials post any questions have in the comments and i'll see you next time
Info
Channel: Code Monkey
Views: 195,678
Rating: undefined out of 5
Keywords: unity visual scripting, unity bolt tutorial, visual scripting, unity visual code, unity no code, unity visual, unity bolt, bolt visual scripting tutorial, unity dots, unity vs, code monkey, unity tutorial, unity game tutorial, unity tutorial for beginners, unity 2d tutorial, unity 3d, unity, game development, game dev, game development unity, unity 2d, unity 3d tutorial, programming, coding, c#, code, software development, learn to code, learn programming, unity bolt 2
Id: 8y6akNTUt2Y
Channel Id: undefined
Length: 13min 9sec (789 seconds)
Published: Sun Jul 26 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.