Godot 3.2: Let's Build a 2D Platformer!: Part 12 (Coin HUD, Custom Signals & Fixing Double-Collect)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Wow, so quick! Thank you so much.

👍︎︎ 1 👤︎︎ u/VRbandwagon 📅︎︎ Jun 28 2020 🗫︎ replies
Captions
hello and what's work 12 let's create a 3d platformer in the Godot game engine my name is Colin and this tutorial not so many series we're creating this 2d platformer video game of course in this game you control the player on screen using keys on your keyboard of course you can walk run jump and fall you can collect coins squash enemies get hit by enemies and lose lives shoot fireballs you know how to deep lat former games work so as it stands at a project right now we have a character that can explore a large world and as of the last two videos in this mini series we have coins in our game level so now if you collect a coin if your character collides with a coin that coined is a little balanced animation the coin will disappear and you will collect a coin your character keeps track of how many coins you've collected and if you collect all the coins in your game level or the number of coins that you specify as the programmer of your game your game will switch scenes to perhaps a you win screen in our case right now we're just switching back to our game level we're resetting our game back to the beginning but you might have noticed that on the screen right now there is something extra there is a coin counter on the screen that is basically sticking to the glass as my game camera moves which follows my character around this coin counter is called a heads-up display a heads-up display or HUD for short in a game is information that sticks to the game camera that follows your view around that gives you more information and in this case of course it's a coin counter so that's what we'll be making in this video of course if you have not seen the last 11 parts of this mini series and how to create a 2d platformer in the cadeau game engine I'll put a link to this whole playlist containing all of my kiddo 3 tutorials up on the screen right now so click that card if you're missing if you haven't seen anything these past videos and check them out but let's go ahead and jump into the kiddo game engine of course if you like this video or know something it please go ahead and click on that like button below this video it really helps help me in my channel if you want some more videos like this one in the Godot game engine or in blender or other technology click on that subscribe button as well and click the bell icon to be notified whenever I upload a new tutorial so as it stands in our project right now we have a little character that can explore our world I'll go ahead and press the play C button to test it out at the start of this tutorial so right now if I move my character around and I jump and I collect the coins what's happening right now is that my character is the object that's keeping track of how many coins have been collected and so you can't see visually how many coins have been collected so you can't really track your own progress so let's fix that let's add a HUD to add a HUD into your game something that sticks to your camera's glass essentially you're gonna be adding what's called a canvas layer node so I'm gonna select the root node of my scene and again this node a canvas layer kind of acts in a funny way it doesn't stay with the other objects visually in your screen it's a canvas layer which means that is kind of separate from everything else in that it will not move as your camera pans around it'll basically again stick to the clasp of your camera so what the root node of this level selected I'm gonna press the plus button and I'm going to add what's called a canvas layer node and I have to search for that all in one word canvas layer and it's right there so I'll double-click on this canvas layer node to add it into my node tree there it is I'm gonna double click on this and name it HUD HUD all in capital letters but I'll come into play a little bit later and I'm gonna select this note because to it I'm gonna add a child node that's of a certain category that works really well with these canvas layer nodes the categories all selected the category is I'm gonna clear my search out called a control node and this is kind of the parent node of a whole sub branch of notes a category of nodes these are all user interface nodes that work well with these canvas layers these user interface nodes are all green so they're easy to find and the one that we're gonna add is just gonna add an area onto our screen that kind of forms the area where the user can look to see the coin counter on screen so this is called a panel in fact it's right here if you need to search for this PA and al you can do that I'll double click and as you can see if i zoom in on the kind of origin of my scene a panel is just by default a black rectangle or square I can drag the corners to make it bigger but what I'm gonna do is select this panel note I'll pan over in my scene and I'm gonna go over the inspector with its so elected over here and I'm gonna give it a custom style so I'm gonna expand out this custom style kind of section and we're gonna give it a custom style called I'll click this little arrow called a style box flat this is one of the ways you can style things in Kudo especially user interface elements there's also themes which is more versatile I'm not gonna get into that there were at least not in this video so custom style and new style box flat when we make this panel have a style box flat style I can click right on that word style box flat and it'll expand out this sub section so I can edit the properties of this style box flat and I can choose a background color so I'm gonna give it at least for now a black background but I'm gonna turn down the Alpha the transparency slider so it is now see-through and that's kind of nice I'm gonna expand out the corner radius section because I want to give this section kind of nice round corners so I'll click in each one of these top left and type 20 I'll press tab 20 tab 20 tab 20 and now if I press Enter all the corners have a nice rounded corners so where should I put this panel well we're not gonna position this panel in relation to our game's camera in fact we want to when we make a canvas layer position any UI elements that are part of our HUD in relation to our default game window rectangle which is right here on your screen I'm highlighting it with extra UI elements in the video right now so you can see it but it's not as obvious in the Godot engine so in relation to this rectangle we're going to a position our panel right about there okay and maybe I'll make it a little bit bigger now in this section I'm gonna have a little coin icon and then we'll have a letter X just to mean x and then we'll have a number that says how many coins we've collected to get that coin icon and to use fonts in our game we need external assets which I'll be giving to you in a download link below this video on YouTube I've got two folders here HUD and fonts and so what I'm gonna do is select them and of course when you download these you might need to unzip them and then you're gonna want to copy them so I'll right click on them and say copy I'll go into my game project folder of course I have an assets folder here I'll go into that and I will in fact I already have a fonts folder which I will delete I will paste those fonts and the HUD I'm giving you a font it's called balsamic sans and this is the bold variant of it you can get this font from google fonts and if you go to google fonts which is fonts google calm and if you search for balsamic sans you can click the download button to get all of the variations of this font for yourself I'm just giving you the bold version now when you're making a game and you're going to eventually export it and distribute it on the internet or you want people to download it and install it you have to include the fonts yourself you can't rely on somebody else having the exact fonts that you want to have in your game already installed on their computer you have to put the fonts in your game project folder okay that's why I'm giving you these fonts or this font at least for this part of our game project in the HUD folder I'm giving you the picture of the coin that we're gonna be adding into our HUD okay it looks different than the coin in our level so the user doesn't get confused on their screen so there you go we've got two new folders I'm gonna go back into the cadeau game engine and it'll quickly import those things so down in my file system dock in the assets folder I've got the HUD folder with the coin and the fonts so now we're gonna add the picture of the coin to our HUD panel so I'm gonna select the HUD root node and I'm gonna press the plus button we're gonna add not a sprite you might be expecting that because the sprite is how we normally add a picture into our game we're going to instead use one of those green control based nodes we're gonna use the texture rectangle in fact if I search for text sure if I click on the search and actually type that texture correct that's what we want texture rectangle it behaves a little bit differently and it works well with canvas layers so I'll double click on that and it gets put right here to rectangle I can have a texture in it it has a spot for a picture so I'm gonna go to my file system dock and I'm gonna go to my HUD assets folder and drag that picture in to the empty texture there it is you'll notice that if I try scaling this texture rectangle it doesn't do a whole lot because I have to select and turn on that texture rectangles expand property and then I can squash and stretch and you might have to play around with this scale on expand because you might not be able to make it smaller in some cases I'm not sure I'm just gonna kind of position it like that that's just kind of move it around a little bit and make it kind of nice I believe if you hold shift it should not stretch it if you do that when you first start stretching it around okay so that's how our HUD looks right now it looks pretty good let's go ahead and select the root node and I'm gonna press plus because now we're gonna add a little X and this is the first time what we're gonna be using a font in our game but to add an X which is just text we're gonna be adding that what's called a label known so I'll select label I can of course search for label in my search bar I'll double click on it it is right up here I'll drag it to right about there when you have a label node selected you can type in text property box in the inspector I'm gonna type the water lowercase X and if i zoom in because that's what it's gonna take to see it it is white in color or light gray and it is really small and it does not use a font how you get fonts into labels in guro is you have to select the label and then you can go down to there's lots of properties in the inspector for labels you have to go down to custom fonts and this custom fought is actually not where you're gonna drag in the font file to dot t TF font file if you drag that in there it won't work what you have to do is create a good or resource so what we're gonna be doing here is next to empty I'm gonna say click on me a little arrow and say new dynamic font and once I do that this is a cadeau resource that you're going to bring a font file into so if I click on the word dynamic font it'll expand out a section just like before and with this section expanded now I can open up the font section and drag in the font data which is actually gonna be our font file I'll drag them that go so now we're using this font called balsamic sans it's too small so under this dynamic font our resource there is a settings category this is where we change the size of the font so I might try something like 40 maybe something bigger like 52 I don't know you can play around with that and I'll move it up so now I have coins times and the font color is a little bit below that section so if I collapse dynamic font there's a custom color section where I can enable a font color and so what I'm gonna do is try to pick with the color picker a color that looks a lot like that gold color of the the coin so I like that I'll just click somewhere else let's go ahead and create the actual text for the number of coins that we collected so again I'm going to before I actually add that I'm going to make this label called X I'll just rename it X and press enter I'm gonna select the hutt again I'll press plus you know what's happening here I'm gonna find the label I'm gonna double click on it and I'm going to move it over here I'm gonna add instead of a number I'm gonna add two pound signs or hash tags so I can get an idea of how big this item this text should be even though it's gonna contain a variable so we want to scale this text and use fonts and/or font and color to it so I'm going to with the label selected I'm actually to call this label coins okay and I'm gonna put coins with a capital C you'll see why a little bit later so we don't get confused so this coins label or we're going to give it a custom font again I'm gonna make a new dynamic font resource I'll click on it open up the font subcategory and I'll drag in that balsamic sans font and I'll go to the font settings and I'll change the size to only be something like 60 and I'll drag that up and I'm gonna see if I can match the color of the X font so I'll click on it in fact with a color picker you can copy this hex value which is my case FF c c 1 d a hex value is base 16 it's a number that most computer programs used to specify at color in the 8-bit color space in most programs that's what you're using so if I go to this label I can not use the outline color I'm gonna use the font color and I'll enable it and I'll paste in that ffcc 1d color and I will press enter and now it is that color okay I might make that font a little bit bigger maybe 70 or so and I will make it so that it is aligned and where is that alignment that's reenter the top properties of this node I'm gonna say V align Center and align left so if I make this bigger it will stay centered up and down because I have a line feel line Center and I'll put it right about there okay so now if i zoom out let's see how that looks and you're not gonna do of course I'm gonna save and I'm gonna press the placing button and we'll see if this works I've got my coin counter up here I think it's too big but I'll fix that after this video but now if I go and of course walk around my level and make the camera move to follow me it is staying on my screen quite nicely to make it actually display the number of coins that we have collected there are a few steps here first of all I'm gonna go down to my HUD this is my branch in my main level one scene and with the HUD selected which is of course a canvas item I'm gonna press the ad script to it so I'll have it selected I'll press ad script this is gonna add a new GD script file of course it'll be called HUD GD I like that the template I'm gonna use is gonna be no comments this is cleaner than just leaving the default because if it puts a bunch of comments into your code so I don't want that so I'll say no comments and I'll press create it'll be called HUD dot GD now when HUD first loads in the game we want the HUD to not have its coins label say or have those two visual pound signs or hash tags in there we want to write when the game first loads change those to a number value so that is actually a good use for this function called underscore ready that we haven't talked about yet in this tutorial series so far this ready function that we've always just a leered is actually a function that runs whenever unknown first launches into our game and when the note itself is actually ready to start running code well this ready function automatically runs so what I'm gonna do is I'm gonna say hey go get your coins child node and access its text property and make its text equal to zero how do we do this well to access another node in your scene especially a child node from a node that you are working on you put of course instead of this past line we'll get rid of that I'm gonna say you put a dollar sign and when you put a dollar sign this is how you access child nodes again and you can just put the name of it so in this case I'm gonna say coins and this coins has a capital C which matches this one and now that I have that if I put a dot this is how I can access any of the properties of the coins object or any of its methods in this case a label has and if I actually click on the coins label it has a property called text and we can actually access this using code from the HUD object so I'm gonna go back to my HUD script and I'm gonna say coins dot and it's text just like that txt it's lowercase even though it was uppercase in the inspector so now I can say hey make this text equal to and I'm just gonna put something silly at first I'm gonna say make it equal to Bob except when you assign a piece of text to the coins text you have to put it in quotes so I'm gonna put in quotes Bob and then I'll do a quick ctrl s to save and I'm on my level 1 scene now so if I press the play scene button well it says Bob okay how do we make it say a number well it's not quite as easy as just putting a zero here because when you type a number zero gadot will recognize that as an integer an integer is a whole number that does not have decimals in it and those two types of numbers numbers that are integers that don't have decimals and numbers that do have decimals are a little bit different in most programming languages so if I try to run this I press play scene I will get an error and what my error says in the debugger because it just crashed essentially is invalid set index text on base label with value a type int + int here means integer so what this not so easy to understand error says is that we're trying to assign a number into a text property that's expecting a string and a string is a piece of text with letters and characters but a string always has quotes like that now this doesn't work for us though because we want to actually be able to count with this number so what I'm gonna do here is I'm gonna run or call a function that's built into Gd script called string and the string method will convert what you give it it's a method call so you need round brackets whatever you put of different types of data in the round brackets will get converted into a string so now we're converting the number integer 0 into a string just so that a text will accept it and be happy with it and understand what to play in its text label okay so I'll press ctrl save or ctrl s on my screen I'm gonna press the stop button it might not me save until I press stop and I'll press placing and now it says zero on my screen but just having the number zero is going to be enough we want to keep track of our coins with a variable so I'm gonna keep track of on my HUD now the number of coins that we have collected in our game so far using a variable so above my ready function I'm gonna type far now I'm gonna use the word coins and I'm using coins with a lowercase now just so we don't confuse it with our coins label that's why I did that so far coins I'm gonna make it equal to zero and whenever we collect a coin we're gonna add one to that number and you'll see that you've already seen something very very similar in the last video okay so now instead of just saying that convert the literal value 0 into a string and put it in text we're gonna convert this coins variable and put it into the text as a string so I'm gonna say coins in there so now if I do a ctrl s to save its coins not just coin if I do a ctrl s to save and I press play seen now it should say 0 if I make coins equal to 6 and I do a ctrl s to save and I press the play seen button it'll put 6 in there so I'll close that and I'll change this back to 0 ok following me so far but we don't really have anything functioning yet in terms of our HUD it's not actually going to count anything yet if I go back to my 2d workspace and I press play well it just displays this 0 on the screen and it's not gonna change if I'm counting my coins my coins are making my character still count okay so if I collect I believe it is 3 coins then I'm gonna reset my game and nothing is happening here what I need to do is change the way my coins are communicating with the rest of my scene so that my character is no longer the object that's collecting coins or counting coins in the background it's gonna be my actual HUD and the HUD itself even though the HUD is not a visible object is just the kind of container the route of the rest of the things that you see in the HUD this HUD has my script on it it's the object that actually does the counting the logic and it has a script on it and it has the coins variable so that makes sense if I select one of my coin notes over in the scene dock and look at its script to actually open up its scene I'll click on a little scene icon on any of my coins we're opening up now we're in our coin scene the original scene that we were instancing and I go to the coin script you can see that it has a function called on coin body entered which is linked up to a signal that detects if a physics body enters that that's why it's called unclaimed body entered and when it detects Steve or any physics body that can be detected by it enter it it's going to play the bounce animation and it's going to access that physics body that collide with it and it's gonna run a method in it or a function in it called add coin this add coin method and the body well this is referring to of course our character and our character has an add coin method on it but we're not gonna use this anymore so I'm gonna get rid of this line of code it's gone so now what's gonna happen is when our character enters the coin well the coin is gonna still detect that like if I select my coin and I go to my node dock it still has the body entered signal that is still running the on coin body entered function so now if I go back to my script yes it is still connected it still will work it'll play the balance animation and when the bounce animation finishes it will run this function which makes the claim disappear but right here we need to send a signal to our HUD that a coin has been collected and this time we are gonna have to use a signal but there is no signal built into an area 2d so if I select the root node which is an area 2d and I go back to my node dock and look at all the signals there really is no signal for this specific instance these signals that come with any given object are common things or events that could occur for that kind of object but this requires a custom signal so on my coin I'm gonna go to the coin script above any of the other functions but below the top line I'm going to create a new custom signal so I'm gonna type signal this is just like making a variable and I'm gonna call this coin underscore collect it with an e enemy B okay so spelled correctly and I'm going to when a physics body enters this coin when this function runs and the animation player plays its balance animation I'm now going to emit that signal so I'm gonna press Enter and lined up with the previous line of code right indented under this function of course I'm going to say emit underscore signal this is how you eat MIT a custom signal or really any signal this is a mythical so I need to put my parentheses or round brackets and in here I'm gonna put in double quotes coin collected the same name of my custom signal so coin underscore collect it spelled correctly hopefully okay but on its own a custom signal like this doesn't do anything of course unless you connect the signal up to a method or function that you have somewhere else in your program or perhaps on this code itself in this case I'm going to emit a signal that's going to be connected up to my HUDs script and my HUD script will have a method on it or a function on it that will run whenever the signal is emitted and it responds to it and it will add one to the coin variable and it will be responsible for keeping track of how many coins are collected how do you do this well I'm gonna save this coin scene and its script so I'll press ctrl s I'll go back to level one and I'll go back to my 2d workspace and if I select any of my coins now coin one is as good so I'll select clean one you'll see that under the node dock there is a new custom signal here it's the one that I just made called coin collected and it's not hooked up to anything it doesn't have one of these little green icons below it so what we're gonna do here is in the actual scene on this coin one instance of the coin I'm gonna hook the signal up to something else in this scene we can't do this step at least as far as I know at least as far as we're gonna get in this miniseries on the original coin scene which would be nice because this coin scene doesn't know what else is in the scene that it's being put into that it's being instance into so we can't really assume that there is going to be a HUD in our scene where the coin is so that's why we have to do this on the instance or each instance of the coin so I'm gonna select coin one and now that it has a signal I'm gonna have or custom signal I'm going to double click on it and now in the scene where this instance of the coin is I'm going to select the node that I want to put the code on for the signal in this case I'm gonna select of course the HUD because that's what it's gonna send the message to so I'll select the HUD it has a script on it I'll press connect in just a second but it's gonna make a receiver method or a function called on coin 1 coin collected that's too long and it doesn't work for all of our coins because it says coin one so I'm gonna get rid of coin 1 and just say on and I'll get rid of a couple of or the extra underscores there this method or function is gonna be called just underscore on coin collected and I think that's short and more to the point so I'll press connect and now if I look at my HUDs script which is what this is there is a new function here called on coin collected and this function of course will run whenever a coin is collected and what I'm going to do here is say make coins equal to itself plus one you saw this in the last video so I'm gonna say coins is gonna be equal to coins plus one and that's how you write the code to make a variable add one to itself and then store that itself plus one back into itself okay it's kind of a weird way of saying hey add one to that variable but that's how you do it but as it stands even though our variable is being updated here we are counting the coin properly it's not going to show up in that label that we have on this Green called coins with a capital C so if I were to play this right now I'll do a ctrl s to save and I'll I'm on level 1 now I'll press play seen it is kind of working here I have it displaying 0 which is my coins variable and if I go and collect a coin especially that coin 1 it did send that signal it did actually count to 1 hopefully but it didn't change because we haven't changed this label yet to do that well it's actually the same as this line of code here but I don't want to be redundant here so I'm just gonna call this ready method again R that's ready function again so under this line I'm gonna press Enter I'm gonna call underscore ready again and yes you can do that ready there we go yes you can call that method even though it's not gonna be running it or you're calling it that's not time that's not at the beginning of your game that's just fine so I'll do a ctrl s the same and let's see if this works if I press play seen with level 1 selected it should display 0 and now when I collect a coin it changes to 1 good ok let's go and see if this keeps on working if I go and collect the second coin and nothing happens and because with that second coin and my third coin we didn't hook up the signals yet so if I go back to my 2d workspace if I select coin 1 this coin pocket signal is hooked up to our HUDs on coin collected signal but coin 2 isn't coin 3 isn't so this is where I can have to bite the bullet here you'll either if you already have tons of coins and you already had them laid out exactly where you want you'll need to go to each coin and double click on coin collected and then you need to make sure that you're hooking it up to the same signal or the same function pardon me that you were before so it has to be the exact same name on coin collected just like that instead I would recommend that you just set it up working on one coin so in this case coin 1 I'm gonna select coin 2 and get rid of it right click delete nodes yes please and coin 3 and delete nodes and while we're here why don't we actually lay out our coins using some snapping and a grid recall from a previous video where we set up our I think it was the one-way platforms that there is snapping and a grid in Godot you can snap to a grid and our grid is set to 32 by 32 if you click on these three little arrows you can say configure snap yeah these three little arrows is actually a little menu and I'm gonna change grid step to 64 and 64 pixels and I'll press close so now if I drag this point around it'll snap nicely not we'll make it so that my coins are all nicely aligned and so they're not all wonky also I might want to put all of my coins in sort of their own branch and kind of like a folder in our node tree so I'm gonna select my root note here and I'm gonna press plus I'm gonna add just a node to D and this is just gonna act like a folder so if I double click on node T to D or search for it and then add it I'll double click this is gonna be like a folder for all night coin so I'm gonna name this coins and I'll press enter I'll drag my claim into that and I'll select it and it is all the same that I'm expecting and I can now go ahead and of course move it to wherever I want I'll put it to be right about there or so and now I can just right click on it in my node tree and I can say duplicate and now it'll name the next number nicely so now if I drag it up you know it'll go there if I right click and duplicate again it's all set up and I can just drag this one over and if I select any one of them and go over to my no dock you can see the signals are all working so now if I press play seen hopefully now I'm starting off with my HUD counter at zero and I can collect one two and three coins but we haven't won the game yet we haven't switched scenes so for that this is gonna be exactly the same as with our character in fact on my character I'll go select my steve node and go to his script i have the code that we need we have inside of our physics process delta function we have this if coins equals equals three change my scene I will zoom out on that so you can see all of it in Godot so right there I'm actually gonna cut that control X on my keyboard because that's not gonna be on a character anymore in fact we don't need this function add coin anymore so we'll get rid of that as well and now let's go to our HUD so I'll go to my HUD and my HUD script we need to add that physics process Delta game loop to our HUD so I'm gonna go above my last function that's generally where it goes func underscore physics process Delta it's built into code oh so they'll know what to type and I'll press Enter and now I'll paste that if statement so now if my coins variable will just mean the same as I had it before is equal to 3ei I'll switch back to level 1 if you need to pause the video and get that code for yourself please pause the video but I'm gonna press ctrl s on my keyboard and I'll go back to my tree workspace and I will press play scene and now my game loves and if I collect three coins hopefully I win the game and my game resets okay we are almost done but there is a logical problem with our game and I'll illustrate that right now if I press placing and I go and collect a coin and this problem was brought up to me in my last mini series in Godot in my 3d basic game if you collect a coin and then as the coin is doing its little animation and you go out of the coins area and then back into the coins area you can actually collect the same coin twice thank you to that commenter who let me know that so the same thing the same logical error is happening here if I go into my coin and quickly go back out of it it didn't happen there but let's see what happened actually did happened just there because I collected just two coins and it reset my level if I do that what just happened well I went back and forth and I have two coins what's happening there is of course when I go up and collect a coin I am entering an area and when I enter an area it emits a signal to go and collect and run some code to add one to our coin variable on the HUD and if you go out and quickly back into that area as the coin is playing that animation you are triggering that same code twice and you are therefore adding two to that variable instead of just one how can we fix this problem there are a few different ways we can do this but the easiest way is if I go to my coin scene and I go to my coins code of course we have a function here called on coin body entered and this is of course the function that gets run whenever your player enters the coin when that happens of course we're running a animation or play an animation called bounce to make the coin go up and down and we're emitting a signal called coin collectors that we actually count the coin but when that happens we want to disable the coins ability to be able to detect any more players entering it so we're gonna be doing here is we're just going to play and edit in the game or collision mask of our coin so if I go back to our 2d workspace in our coin scene if I select the root node of my scene of course over in the inspector and the properties we have a collision section and our coin object the area 2d doesn't actually belong to a layer now we have a layer for items at our game if I click on this little two dots here we have I believe it's the fourth layer four items but we don't actually put the coin on a layer because we don't need the player to be able to detect coins we just need the coin or all the coin instances to be able to detect players and that happens of course using the collision masks down here if I click these two little dots you can see that the coin is able to detect players and so this first layer this versatile box is enabled what I'm gonna do in my code is disable this right after a player enters the coin okay or the instance of the coin how do I do that well if I hover over this little square you can see that this layer it says bit zero and value one and so I'm gonna use a method call in my code of my coin to turn that off to set the value of this Square this layer to false we're gonna turn it off so I'll go back to my claims script and right here when we're entering the coin with the character I'm going to call a method called set underscore collision and it's called set collision masks bit so I'm going to use my down arrow key on my keyboard select that second option press Enter now as you can see because it's kind of prompting us here it needs two values it needs a bit value in other words which bit of all those little squares which layer are we targeting and what value are we gonna give that bit are we going to turn that bit on or off so if I go back to my claims properties and go to the mask bit you can see that it is bit zero and it has a value of true right now so it's the bit value that we're looking at not the value okay so if I go back to my coin script and I say zero for bit zero and then I'll put a comma and now it's looking for a boolean value which basically means just true or false in this case I'm gonna say false so now I've turned the collision mask off so hopefully that should work I'm gonna do a ctrl s to save if you need to pause the video go ahead and do that now but I'm gonna go back to my level one scene and I'll go to my 2d workspace and I'll press the play scene button let's go ahead and try this out if I go over with my character and try to collect my coin twice it just doesn't happen okay a little bit slow there let's go ahead and try that one more time I'll go and collect my coin twice and I can't collect it twice anymore so that has worked okay so that will be it for this video we've solved quite a few problems here and we've added a HUD in this video of course if you like this video for loading something in it please go ahead and click on that like button lowest video it really helps up me my channel and I really appreciate it if you want see more videos like this one in the cadeau game engine or in blender or other technology click on that subscribe button as well and click the bell icons below fight whenever I upload a new tutorial check out my facebook page and my Instagram page in those two places I post sneak peeks and previews of what I'm working on next but that'll be it for this video thanks for watching we'll see the next one [Music] you
Info
Channel: BornCG
Views: 24,049
Rating: undefined out of 5
Keywords: tutorial, lesson, beginner, godot, godotengine, game, engine, program, code, platformer, platform, jump, gdscript, coin, collect, display, HUD, heads-up
Id: XITNApxoIes
Channel Id: undefined
Length: 40min 18sec (2418 seconds)
Published: Sun Jun 28 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.