Unity Dev first Time looking at: Godot - Episode 3: Nodes & Areas

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's continue to take a look at Godot alrighty friends us back in a good dough again and this time we'll go supercharged with some of the things that we're going to take a look at so first of all I had a couple of hours and a day to sort of think about a few things and the first thing I did discover is that well you can of course change the class that this extends from and then all of a sudden right you get access to I mean the transform over here you get access to the translate so I've actually even changed the move towards method here to being translate over here it makes it so much easier because if you actually take a look at the Godot one so for people who are already familiar with Godot you're gonna be like yeah this is pretty obvious but once again I'm coming in here completely blind and here these would be all of the things that are available from the node class right and then we have also things from the canvas item and then here we have things available from the node 2D which specifically is the transform that's the big thing that is specific for only a node 2D so that is a one thing that is kind of interesting and there's also one thing that I've discovered and that is that you can only put a one script on each of your notes so if I wanted to for example add another script to my character right here what I would have to do is I would have to add a child node right here but what's very interesting is that it basically when you do that it gives you a possibility of adding all sorts of different kind of nodes right here which is freaking crazy right so I could add another 2D node for example over here as you can see like those bones audio listeners I could add markers I could even add a timer apparently which is I don't even know how that works but it is absolutely crazy and I think that that's pretty freaking cool I think that that's a very interesting way of doing it so each node has its own sort of responsibility I don't know if the right wave for example would be if I were to change this you know this would be now that you player for example right let's just say it and I wanted to have well I now want my health script right so coming from Unity right I would make a health script and I would just attach it to the player I would then be like okay do I just add it as a as another node right do I just add another node right here and I would call this like the Health node I'm just once again saying this and then you know adding a new script right here I'll call this the health script maybe and this is going to be under C sharp that's okay and this is going to be a no that's fine I don't think I want to do object I don't think that's quite right I'm going to create that and then we have the health script and we could you know do some stuff in here but what I'm going to do now is I have the possibility of being able to run with this guys so I can I can move him about right here which is pretty cool and I would just want to like add a some sort of area that you know just happened so basically some sort of collision I just want to do some basic collision and just see how that works so I would assume that I probably needed to add a child over here let's just see if there's any Collision so there's a collision shape right here which is also a node 2D that that would probably be what I want to do a collision shape which provides a shape 2D and a collision object parent let's just create that and see what happens so this doesn't work because it doesn't have a collision shape ah so we want to do that as a child of an area 2D static body to re rigid body 2D or a character body 2D okay then we will chain let's do a character body 2D then let's create that under the player and then we're going to take the Collision shape below that there's still something and that is the shape must be provided by the Collision shape 2D function these create a shape resource for it okay that's you know this giving us the warnings right here I actually enjoy that that's pretty interesting so let's then create the rest Source this is a resource right and they said it would be a shape so how about this is going to be a how about we're just going to do a rectangle shape for now so this would be the player shape once again just playing around with this a little bit so this is going to be right here so this is a script and the shape is going to be the player shape okay that's yeah no that's that's actually pretty much what I had in mind over here for the for the Collision shape I mean we can even change this pretty freaking easily over here all right now future Captain Joe jumps in over here as there have been I think like over 100 comments in the first two videos right now uh which um yeah I basically just want to make sure that I incorporate a few of those in this video as well so the first thing that is incredible is if you press F1 bam you get the search and now you might be like okay what can I do with this well let's just say for example I want to figure out what the animated texture is I double click this and I get the entirety of all the documentation right here inside of the engine itself which is that's pretty freaking crazy I also have figured out that using an external editor might be a bad idea so that might not be a good idea at all because there's a couple of things that are just easier done inside of the script editor right here another thing that a lot a lot a lot of people have basically said while C sharp right now is sort of working and you can do it you should stick with GE script that is like one of the big things that a lot of people have been telling me and I actually also think thinking about it for a couple of days honestly it's not that bad like it's really not that difficult to think about it in a little bit of a different way so if we were to let's say just get rid of this and then let's create a new script this is going to be the health note but this time in GD script right so there's the health node.jd when we open the health right here right we get the export right here so then the same thing would be VAR Health equals five I would argue and to let it have it shown in the inspector I would add an ad export if I understand this correctly and then it might work let's take a look right here this is the health node again there we go you got the health right here and that is the thing shown that is I mean that's totally fine and then when it comes to the wrist right when we have the damage method right here I mean the similar thing goes right we would do funk I don't know if you need to start with underscore if that's maybe a convention but maybe we can then call this damn image and we can call this damage and because it's not strongly type it's going to figure this out on its own so that would be so that would be let me just like get this in here and then we can just change this so that would be health is minus equals damage that is correct and then here we're just going to call the print method and then here instead of the Pearly brackets we're just going to have this and then this is also going to be just a print call and all of a sudden this seems to make a little bit more sense I think the comments are definitely right that GD script is not actually as bad a lot of people have said that usually you know people come over and they're like oh C sharp is going to be you know you want to try this out but when you then use GD script it's it's actually fairly straightforward I mean it's basically just python with a few extra steps but I feel pretty good about it so far and now what I actually wanted to do is I wanted to add a new area right here so this would be adding this into the scene and that would basically be an area 2D let's add the area 2D right here so this needs a collision shape again so there's going to be a collision shape I really enjoy the fact that it basically tells you hey you need to add this to the specific node and this needs to be added as well and then in the Collision shape we need to make a new shape for example just a new rectangle and we can make this a bigger here as well and in this case I would make a script for the area 2D because that's good that would be the one the thing that basically sort of detects this so we could call this the attack area script or something like that right so I could do that and now the crazy thing about it is that what I would like to do is I would like it so that when a let me actually make this red so what I'd like to do is now that when an area right with a health node enters into this area that it somehow gets damaged that would be the logical things that I would do once again this is probably still Unity thinking here but I think that that's fair now what I did also fine and this is I'm gonna be real that is crazy so in the node right here you can get the signals right here which I think is actually the thing that you would want to well basically like change right so now my question is can I do it in both ways so I could ask the area I could be like body entered right so this would be a body entered into this area and I double click it and I say I want to then create the on body intro method inside of my script that I've just created and Bam I just created and this will now basically get me hey that something went in there so this is as easy as then just saying for example you know something entered just for the sake of argument right here I'm still I'm still used to the semicolons that's gonna stay for a while I think but there you go and that should actually already work right so if I'm gonna build this okay something is uh a foot but there you go so basically I'm entering into the area and it works this is probably as the name suggests right here it's probably getting the body so this would be I would expect a sort of character body let me find the area 2D so you can control click on well any sort of class or method or anything to get to pull up the docs which is absolutely freaking fantastic now the question is there are the signals so signals or signals are freaking crazy guys they are insane basically an event that gets fired or a or a signal in this case that gets emitted and then you can see like emitted when the received area enters this area that is absolutely freaking crazy cool this is so good this is like so well designed you don't need to check everything for like every frame you can just say hey just when this you know the signal gets emitted then I want to do something really freaking awesome let's just print out the body and let's see with what it is so this is the character body 2D it does make a lot of sense that would be the character body 2D so now I would want to get to the health node now this is the question that I'm still you know definitely struggling with so please do feel free to leave me a comment okay so I understand it correctly that now I have to actually Define specifically what the body is and I can do it like this is this a is this a correct statement and now I get body done and I can get like the parent for example get parent right here bam and then when I have the parent right which would be the player I could I guess get the child and I get the child of index 0 which would get me the health mode and then can I now just call damage over here that is that will be the question we'll just handle this for me because this should be getting the health node right here so this is where I am and now I can just call damage and it's just gonna like do that also this is a C sharp script so wait a second no no this is the health node wait a second this is the health node that would be damage does it like just do that let's uh I mean let's see it is not why not string and integer are not oh okay we can't we can't do that um so the funny thing is the only thing that doesn't work is that this is not being recognized as a string but I think we can do it like that and now all of a sudden health is now four three two one and Bam well that's pretty neat of course the structure here would always have to be the same sort of to make sure that hey the you know you get the parent from the body and then you get the child I believe I've seen this before and that would be great confirmation so a lot of people basically as the root node of their player let's say for example they actually wouldn't put the Sprite they would actually put the body like the body itself so any type of collision object 2D basically because that's what's always going to be gotten through you know for example like an unentered like an uninjured method and then it's way easier to you know you don't have to basically reference the the parent again and then the child you can just be like a child okay so that definitely makes a lot more sense now one last thing I want to do is I actually want to I mean not necessarily like rewrite the the movement script but I wanted to at least take a look at another thing so first of all get rid of the movement script right here again so people have basically said to take a look at the input map which would be under project so under project settings input map apparently you can well you can add actions over here so I mean I it's like something like move left move right move up move down so then it would be oh my God and then you can actually map it to keyboard inputs and buttons and axes that is freaking fantastic man so left I could then just be like hey just put this under so let's I could just put this under the a key over here oh my gosh that is so freaking good okay that makes it actually uh pretty nice oh you can even just enter that there that is so well done so you just listen for an input and then you just put it in there and then they go wow that's phenomenal so then we're gonna add a new movement script again so this is the player movement because why the frick not player movement there you go basically the thing is you can get an input axis via input dot get vector and look at this it actually it gets our predefined things that we have so we can get left over here uh left positive x wait which one is up and which one's down wait wait Negative X is left right and then we have this is neg negative Y and then we have moving up which is positive positive y there you go and then they did tell me to normalize it which makes a lot of sense actually and I think this is the one thing I've been saying basically you shouldn't have the Sprite as the top one for the player but you should probably use the character body over here so if I were to change this up and just do it like this let me just make sure that should be fine and then instead of the player having the player movement script you put that on the top over here which would be the player movement right here so let's just put it in there and then instead of a Sprite 2D it would become a character body 2D and I believe now I have access to the velocity right here which is exactly right so velocity would then just be equal to the input axis here and I should already be able to well I mean to move let's see if this is true let's take a look I'm probably moving very very slowly all right so I was able to figure it out by using the Apparently move and slide method right here which moves the body based on the velocity so that is very interesting indeed so that is one of the things that's a little bit confusing that well basically you have to call a method another method right here to basically do that I also in the documentation for well basically getting sorted with movement it does say that I should basically put this in the function of physics process instead so this should be all right here instead of in the process method but if I do that that also totally fine and you can see I can move now this is not 100 correct movement because well well if I press S I actually go up and I if I press W I go down so the vector lied to me negative Y is up and this is down I I saw a few things about the the weirdness of of what's up and down but I guess I guess that's fine there you go that's going to be okay and that is working I guess you would probably want to add a little bit of right here maybe 500 and then oh there you go now I am oh yeah of course now now we're getting an error right here because I didn't change this but now we're we can get the first child and all of a sudden bam I can do this again and everything is working perfectly so what am I taking from this episode well the first thing I'm taking from this episode is that it is probably honestly using GD script is probably just better while yeah C sharp I mean it seems to be working and it seems to be fine while when it's added we're learning something new learning the language over here it really shouldn't be anything crazy because let's be honest a lot of languages are very similar and it's not like this is all of a sudden like a completely different language where everything is different I feel like this is pretty straightforward and the second thing to think about is sort of the setup in the nodes right here I mean this is still definitely one of the things that gets me to I mean basically I have to completely unlearn what I already know in order to sort of wrap my head around the setup of the notes basically but I think I'm getting a little bit closer to it so I definitely appreciate any type of comment that does you know demystifies anything basically but that's gonna be it for this episode on the left side you can get the last episode for the door and on the right side another engine where we're gonna you know stupidly run around and see what we can find hope to see in one of those videos and until next time so yeah
Info
Channel: Game Dev By Kaupenjoe
Views: 6,125
Rating: undefined out of 5
Keywords: Kaupenjoe, Godot, Godot Look At, Unity Dev Looks At, Unity Dev, Game Engines, Game Engine Godot, Godot Games, Godot Tutorial, Godot Unity Comparison, 2D Game Godot, Testing Godot, First Time look at Godot
Id: jY_sJqSmw0g
Channel Id: undefined
Length: 15min 53sec (953 seconds)
Published: Wed Sep 20 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.