Bolt Visual Scripting For Beginner #1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we'll make a simple player that goes up and down left and right and then suits bullet with bold visual scripting now bolt is a way of programming your game without writing any codes it is really great for beginners artists and game designers because you can literally see how your code is running that will help you find your mistakes and solve it pretty quickly and it is really fun to use as well so with that said i'll try my best to make this video as beginner friendly as possible so with that said let's get started so hey this is chrono ab here to make you just a little bit more better in game development if you like the content in this channel then don't forget to hit the subscribe button because 90 of the people don't subscribe to the channel so if you do like the content consider subscribing so first of all let's start by installing bold for that you need to go to your asset store and nowadays you don't have it in here because to improve performance in the editor we don't put it here anymore so we have to go to our online store then in the online source search for both b-o-l-t you'll see something like this and put it in your own asset after you do that go to your windows package manager and you will see all of your assets here you have to go to your packages and it will be here first of all go do my assets and you will see all of your asset then you'll see bolt here downloaded after that it so let me hit import and montage [Music] so after you do that bolt has been imported now go to your tools you'll see a new new place here called tools and install bolt so just import it it will take some time so once you have done that this comes here let's hit next now there are two naming scheme whichever you want you can put it one is human naming scheme and another is programmer naming scheme so whichever feels easier for you if you're really new you can start with here if you have been doing programming then you can start from here whichever you choose both of them are mostly the same so i'm going to choose programmer naming so there will be many things here just hit next you don't need to set up anything here after that just generate so after that you can hit close okay now let's code our player so in our player i will hit add component and i'll add a flow machine click there then you need to create a new macro i'm going to click on new macro and i'm going to put it in here let's say a new folder called macro and i'm going to call it player move and shoot maybe something like that once you do that you can give a title so player movement suit again and in summary you can say what this code does so in my case it will move up and down left and right and then shoot bullet now after that let's click on edit graph now you can see a flow graph here with a start and update event node right we need to add one last thing here which is on windows graph inspector and i'm going to put it down here what this does is basically tells you what every node does so this node is the start node and this only gets called once when you start the game and this gets called until you close the game it will keep on getting called every new frame let's say in our stat let's say my game runs at about 1000 frames per second that means this will be called 1000 times every second so that is how it works so we don't need the start function right now so let's just remove this and in the update let's do something let's just hit play and the first thing we want to do is in our player we want to rotate it rotate on the z-axis like this right so let's make it happen here i'll just click on this then click up here now we are going to rotate the player right so it's it should be inside the player it will show us everything that is in the player it's the whole game object or the transform or the sprite renderer that is all three we have we have the game object which is the old thing and the sprite i mean transform and the sprite render so we want to rotate it so we have to go inside transform and there are many things we have to find the rotate function so it will be called rotate and we can rotate it on the x angle or the y angle or the z angle so i'm going to click on rotate and now it has started working already but as you can see we have not rotated anywhere so nothing is happening the moment i write one here as you can see it starts spinning which is awesome if i increase the value let's say 10 it's power it spins really quickly and if i write -1 it goes to the other side same for the y-axis as well but it looks a bit different yeah and if i do one on the x as well i don't know how it looks holy that looks kind of cool right so we're not going to rotate it so let me just delete it but we are going to move it so to move it again to this but this time i'm not going to go through here because the more faster way is to basically just search it so i'm going to write translate a t t-r-a-n-s-l-a-t-e it will search for everything and then find the translate so transform.translate on the x or y or z axis so now if i write one here it will start moving on the left side but before that let me just reset the values here okay once i've reset everything i'll put one here and it'll start going to the right side see if i put a minus 1 here it will come back and start going to the left side as you can see let me just make it 0 again again here let me just make it 0 again so that we can see and if i control the y axis meaning put 1 here it will go up and if i remove this put minus one here it will start coming down eventually so that is how it works right which is awesome so now we are going to control this player by using an input so we have to call an input node here by right clicking here add unit and let's write input and we are going to use input dot can access what it will do is that let's go to our project settings and in the input manager you can see many axes right and we are going to use the horizontal axis which give which is which has key binding of a and d and left and right key meaning whenever i press the a key i will get a negative one value whenever i press the d key i'll give it a positive one value and on the left and right also that same thing happens right and because of this we can control the player we can make it control the player on whenever i press the a and d key we can make it go left and right right similarly we have another one called vertical that does the same thing gives us positive whenever i press the up key and negative whenever i press the down key positive whenever i press the w key and negative whenever i press the s key and we can use this to make it go up and down so let's call both of them so let me just make a duplicate of this like this and in the first one i am gonna put first of all vertical one so v e r t i c a l by the way let's go to project settings again you have to write the exact name you have here so for horizontal you have to write it exactly like this and for vertical you have to write it exactly like this the best way to do that is just copy it and then paste it here right let's do that for horizontal as well copy it and then paste it here now we have both controls here let me just put it here first of all let's set up the horizontal one so i will just drag it a little bit further now what we will do is we will first of all connect this then now we will connect this value first of all this so that it flows right this is how you connect everything to this and this runs everything whichever is not connected to this does not run that's why it is grayed out now if i just click here you can see this is the flow that is the flow and this is the axis name according to that it will find whichever axis we want to use right and it gives a result of float and it takes a result of float right so i can just copy this and paste it here once i do that what happens is it is saying zero right so whenever i press the up key it will say one as you can see one and we go up right slowly the player just came out and if i press the down key it will say -1 and we start going down as well so that is awesome we will set this up later but for now now it is going really fast isn't it let me just make it small click here and it's actually going really fast we won't slow this down and the main reason why it is going so fast is because we are using the update function because as i said before the update function runs let's say if the fps is 1000 every 1000 times in one second right your computer might be slower than mine or even faster than mine and according to that it will even move faster or slower so to fix this problem what we do is first of all let's bring out our own speed value let's make our own speed value you can do it in this variable here so let's make a speed value let's just call it speed and it will be a float right so let me just put it down here and the speed let's put it as 25 baby 25 and we need one more thing called time dot delta time so just write delta time and you will get a delta time so get delta time something will that will come out click on it now this will give a really small value which will change according to our fps the more fps we have this more smaller value it will give so we'll have same speed no matter what kind of a computer we have right now because of this my computer might be faster or slower and you'll get faster and slower result in your phone this movement will be even more slower for example right but because of this the movement will be same in every kind of a computer so just remember to add time dot delta time whenever you're using something like speed movement speed so after that what we need to do is first of all we need to multiply these two values and then multiply these two value so how we'll do that is we need a right click add unit and let's call it multiply so we need a multiplication node i'm going to drag this down here and then drag this down here and after that we need another multiplication so i'm just going to click on this and press ctrl duplicate and i'm going to add this multiple this total value down here and then i'm going to add this time dot delta time here so now we have these values right we have been multiplied it and we have these values and we have also multiplied it so now i can go to the y-axis and now our speed is about 25 and as you can see it moves it a really good speed and because of this it'll move at the same speed whichever speed i have set up here in every computer so now let's do the same for our horizontal as well so how i can do that is first of all i need to connect it so i'm just going to connect it here then i'll connect it here and i'll just free up a little bit space so that we can put some nodes between these two and again we need a speed value right so let me just click on it control duplicate let's just put it here and we need our time dot delta time as well control duplicate and i'll just put it here we need two multiplication so let's just make a control duplicate two times and i'm just going to put one here and the other here so first of all i'll just multiply this with this then i'll multiply this with this and now you can move your player horizontally as well but i have to first of all connect this so i'll just connect it on the y axis now whenever i press the a or d key it moves left or right whenever i press the up or down key it moves up or down so i'm just going to try it click on here a and d just does that if i press w it goes up and down and now we have a fully working player which moves up and down left and right and everything else in between so this is a normal script that will make your player move up and down and left and right i'm trying to make a space shooter kind of a game so let's add a function or a system which will help us spawn bullet meaning shoot bullet so first of all i'm going to show you a little bit of organizing tip you can use just click here drag and click select everything then press ctrl and leave it this will be a group let's say this is a group that helps you move the player so player movement now after making this player movement system let's make another system that will help us spawn bullet so for that first of all i need a bullet so let me go here and in the sprite section i have a bullet sprite which is just i have just right clicked and created a sprite here called square and just call it bullet so i'm just going to drag and drop it here and make it about 0.2 on the x-axis and 0.2 on the y-axis and change the color to black okay let's see how it looks and yeah it looks kind of fine now i will make a prefab out of it so in my prefab folder i'm just going to drag and drop it and then in our player i'm going to add two variables the first variable is called bullet and it will be a game object type of game object and here i can drag and drop my bullet great after that i need one more thing called spawn point let me show you okay it looks something like this so just make right click here create an empty game object and call it spawn point right and then give it a gizmo and just drag and drop it right on top of your player so let's make a reference to the spawn point as well so spawn spawn p-o-i-n-t and this will be also be a game object and i'm just going to drag and drop my spawn point here now after that in the flow system first of all we need another input so let's just click here and write input and it will be a get key down so i just need to go down here see input dot get key down click on it now we need to put a key binding meaning what key will actually trigger this so let's say whenever i press the space key we will shoot the bullet right so i'm just just going to put it there and then we need to know if we have pressed the button or not and how we can do that is by using a branch which is inside control and it's a branch so now we need to put the true or false value so if it is true it does something if it is false it does something something like that so if it is true then we will instantiate we will spawn our bullet then how we write that is by writing instantiate instantiate and not we don't instantiate an object we will instantiate a game object so game object which has an origin position and rotation click on it so here if you see here origin means the game object that we are going to spawn position means where do we want to spawn the game object in our case we want to spawn it on our spawn point wherever the spawn point is we will spawn a bullet and for the rotation however the spawn position is rotated which is right now zero comma zero comma zero we'll just rotate it there right that is how we will do that so let's go to our player so we want to spawn our bullet so let me just drag and drop this bullet here and then drag and drop this value here so we will now spawn a bullet now after that we need to spawn it on our spawn point wherever the spawn point is we will spawn it there right so i just need to drag and drop it here but we cannot just do this although it does work but your this value will not know what to take in do you want to take in let's say in the position do you want to take in the position maybe the rotation value maybe the scale value maybe we want to know if it is player or not right maybe take that value we don't know what to take so we have to tell it specifically what we need to take for that we need another node right click unity and call it position there will be a get position value in the transform dot get position so get transform position you'll get this value so click on it and then put it here and then put it in the transform so now we know the transform.position we also need the rotation so right click unit right rotation rotation so we are gonna get the rotation so transform.rotation and it's a get so get transform rotation click on it then drag it here and then drag it here so now whenever i press the space key we will spawn a bullet so let's see if it works or not so i'm moving around everything is running right whenever it's running it it is blue and it's running properly but as you can see after this point it does not run and the reason why is we have to press the space button to make it run right now you see it is false when you click on it you won't see it being true but you will see a little bit of glimpse of it being true you won't see it properly but you get you get the point whenever i press the space key we spawn a bullet and it goes blue for a little bit of time and then it does not so let me do that again see so whenever i press the space key this will be true then we will spawn a bullet on our spawnpoints.position and spawn points dot location and this is the spawnpoint position and location by the way so let's see okay the spawn point c position and location always changes whenever i move this so now i want this bullet to go up right because we are shooting a bullet not just spawning it we want to shoot a bullet so this is done right so i'm just gonna make a group of this let me just do this press ctrl and let's say uh shooting bullet after that we need to program our bullet so we want to make the bullet go upwards so let me just click on bullet then we will add it it's in prefab by the way then we will add a flow machine here then make a new macro and inside the macro i'm just going to put it inside the macro let's call it bullet function or let's say move object move move object so let's edit graph and here also you don't need the start function so remove it after that what we need to do is we just need to make it go up at a certain speed so we need a speed value let's just call it speed in the variable i just put it there is a float and the speed will be 25 uh no uh it is a bullet so yeah 25 will be fine speed is 25 after that i need to just do this and write translate and bring it here and because we want to make it go at a same speed in every computer right we need another thing called time dot delta time so just write delta time and we will multiply basically our speed variable and let me just drag and drop it here so multiply the speed and with time dot delta time and add it here so let's do that multiply time dot delta time speed and you go to x now if i just hit play what will happen is let's call it bullet code here b u l l e t and i don't need a summary forget about it so let's hit play let's see if it works or not so whenever i hit space and it went on the x axis because frankly because i'm an idiot so i put it on the x-axis i should have put it on the y-axis right so let me just do this let me not have this so after that as you can see it is shooting upwards and see this is really great because you can know what mistake you have made instantly the moment you are just playing you can know it and it works perfectly as well which is awesome but if you see here they are not going away if i spawn a lot of them this will just clutter up your scene and because we don't want to clutter up our scene because that will just make the game go slower right your game will be slower your performance will will be slower and game will start being laggy after some amount of time your game will start being laggy so let's have a system which will delete this game object after like maybe uh three seconds how we will do that is by having a system which is let's just go in here and in the flow graph i'll make a function called destroy destroy and we want to destroy it in a certain amount of time so destroy object in short amount of time click on it the time value let's say is maybe 2 second so let's make a variable here called destroy time and it will be a float and let's say we will destroy it in two seconds so destroy time is two seconds let me just put it down here and i'm just gonna drag and drop oh my bad i'm just gonna drag and drop it here and we need a game object to destroy and we want to destroy our own self the bullet that gets spawned right so we will destroy ourselves so just write self self gives us this so we will destroy our own self and that is what's gonna happen so basically we'll just be moving upwards at a certain speed right and after some amount of time which is two seconds for us we will destroy ourselves which is awesome so if i go back now hit play and when i can move i can move okay fine whenever i press the space key the bullet goes up and after like two seconds it just destroys itself as you can see now i can have as many bullet as i want and they will just destroy themselves after some amount of time which is awesome so that is it for this video thank you for watching in the next video we'll make a system where we will spawn asteroid from the top will randomly spawn asteroid from the top and make a system where we can blow up those asteroids so with that said again thank you for watching if you do like the content consider subscribing hit the bell icon to never miss the latest video every new video comes out wednesday every wednesday and sometime sunday so with that said again thank you for watching i hope you liked the video and have a great day bye [Music] uh
Info
Channel: ChronoABI
Views: 22,298
Rating: undefined out of 5
Keywords: Bolt Visual ScriptingFor Beginner #1, Bolt Visual Scripting For Beginner, bolt visual scripting tutorial, Bolt visual Scripting, unity bolt tutorial, bolt tutorial, Game, dev, Bolt, visual Scripting, Making a game with bolt, Bolt Game Dev, Game dev with bolt, Make Games if your an artist, new way of programming games, Visual Programming, Programming with nodes, game development, unity tutorial, unity bolt, visual scripting in unity, game design, bolt 2, unity Bolt 2
Id: q9grOWkzqYU
Channel Id: undefined
Length: 23min 50sec (1430 seconds)
Published: Wed Aug 05 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.