Placeholder Image

字幕列表 影片播放

  • What is up, guys, Back out again with another video tutorial.

  • Let me just review the game that we're gonna create.

  • It's, uh let's see, a duty sh platformer.

  • I don't know the gender of this game.

  • I'm calling Julie, but from what?

  • I don't care.

  • I'm gonna get command and run the game.

  • Just that I could review the game.

  • I also did this gaming unity as well.

  • I called the monster chase, and I'm gonna call a monster chase here as well.

  • So we have our player over here.

  • He is moving, and he needs to avoid these monsters because if they kill him, they kids human.

  • Apparently, I'm very good at this game.

  • Come on, man.

  • Where is the monster?

  • Here from the left side.

  • Because we're random izing.

  • Here's another from the left side and one when it touches me, I'm just gonna resize this.

  • We can play a little bit better.

  • But anyways, when one of these months or touches me and you just saw I'm gonna die, you see, bam, Boom!

  • I have died.

  • The game has restarted.

  • So basically, that is the game.

  • But we will see how we can create and control our player how we can create these monsters, how they can have their own.

  • Aye.

  • Aye.

  • And how we're gonna do all of the good stuff you just saw.

  • So let's get into the video.

  • So the first thing I'm gonna do is delete this editor or close the senator because I have another one.

  • And you don't mind my at a video recording software over here.

  • So what?

  • Here is our new project.

  • The first thing that I'm gonna do is I'm gonna create a to D seen, and this one is going to be game place.

  • I'm going to call this one game play.

  • And in the resource is folder.

  • I'm gonna create a new folder and call it scenes and hit, OK, And in the scene's folder, I'm gonna save the game placing.

  • So go over there and save it.

  • Now, before we continue, let's go over here and import these assets.

  • So these are the assets.

  • I'm just gonna copy them these rights you can Donald Link will be in the description below, so make sure that you, Donald, these assets link will be in the description below.

  • And what I'm gonna do next is on the resource is and go here and located.

  • So open file manager paste them.

  • So when I go back here in my engine, they are going to loot.

  • I'm gonna click on the plus button right here next to game plea to open a new scene because we're gonna create a player.

  • And here I'm going to call this one player because he is going to be our player.

  • I mean, what else can I say is gonna be our player now, in regards to our player, I'm gonna change the type because Greenlee the type is note.

  • Judy, I'm gonna right click on it and I'm gonna go here change type, but I'm gonna filter for Keena Man tick body duty.

  • So dramatic body TV Because I want our players to begin a Matic body duty Commend as to save this in the scenes folders, command has to save it.

  • So what is the first thing to do with our player?

  • First of all, I'm gonna click on the plus button, and here I'm gonna filter for animated Sprite.

  • Actually not spread animation with any made it spike.

  • Here it is that I'm going to call this one animation and let me just zoom in over here.

  • So I'm gonna zoom in.

  • And this is our animation for the player.

  • What we need to do is we need to click on it.

  • So click on this animation over here and for the frames were gonna click here New frames.

  • So new sprite frames.

  • I'm gonna click there.

  • And here we can create our sprint frames So the 1st 1 is gonna be idle.

  • And for that, I don't let me just go here and sprites and player, and I wouldn't drag this one.

  • So this is our idol animations to the 1st 1 The first frame.

  • Nothing too complicated.

  • Next, Right here.

  • It says Idol.

  • You see this box or dis documenting and it has a little plus button at the bottom.

  • Right corner.

  • I'm gonna click on that, and it will create a new enemy.

  • Should I'm going to call this one walk and for the walk of minutes, like the images from do up to seven.

  • And I'm going to do simply drag and drop them over here.

  • So now selecting the animation over here and clicking play.

  • You will see that the animation is playing, but it's playing slow.

  • So I'm gonna take here the frames for a second.

  • I'm gonna see 12 which is going to make them.

  • You see, it's gonna make it a little bit faster.

  • So yeah, this is what I want.

  • And let me just go back over here and turn off the playing and I'm going to click here.

  • I know to plate idol again.

  • So now it's liking the player.

  • You see, we have this exclamation mark over here.

  • We need to add a shape because this is a cinematic body.

  • We need to have a shape on it.

  • Some gonna right Click at the child note and filter for collision shape, duty and attach that collision shape to the on the player.

  • Next, go here inside our shape, you see, click on it.

  • And on the right side, you see, we have the shape.

  • I'm gonna click on that and I'm gonna slug new direct, angular shape.

  • I'm gonna zoom in and move it.

  • Something like this.

  • Maybe with over here and resize it.

  • So this is something you can do on your own.

  • This is nothing complicated, and I'm gonna save it simply.

  • This is the body This is the sheep where we're going to detect collisions when it comes to our players.

  • So when the player touches something in our case, a monster someone touch a monster over here, as you can see on the left or right side, up, above or up above, above er down.

  • Anyways, we are going to detect that collision, but we need this shape in order to do that.

  • So now we have the player.

  • And if I go here in our game, play and take the scene here and put the player inside off the scene.

  • And if some gonna call L Oil on this one instead of running the game, I stopped my screen recording software.

  • Okay, that was awkward.

  • So let us continue command be to run our game, which was which is going to rock me to select which scene is going to be the main scene when it run our game and it's gonna be game place.

  • I'm gonna double click here, and it is going to be game playing.

  • This is what we see Now I am going to resize this a little bit.

  • So in order to resize the money to go on the project project settings and here for in the window.

  • Just finding over here.

  • Where is it?

  • Where is it?

  • Here it ISS window.

  • So the width of my project is gonna be 12.

  • 80.

  • So, HD by 720 the test wit is gonna be 640 the test height is going to be 3 60 So half off this value and we're still not done.

  • Because if I go back here and run the game, you will see what we have to see.

  • You see the players over here?

  • We don't want that.

  • We need to go back again.

  • So project project settings and in the bottom for the stretch, it's disable.

  • We need to set it at duty and aspect is gonna be keep.

  • And now when I come back, a man be we're going to see our player, and it looks really nice.

  • So now we have are really, really cool game.

  • It looks I mean, it looks likes on the window for HD resolution.

  • So what is the next step to do?

  • Let's go over here in our resource is folder and create a new folder.

  • Them when to call scripts so Scripts folder and inside of that folder, I'm gonna write Glick and create a new script.

  • I'm going to choose here, C sharp and let's go over here and you script and I'm going to call this one player and I'm going to get to create and is gonna create it.

  • And here in the deeply scene Select are actually the player seems to like the player and go here for the scripts and load it So from the scripts folder, we're gonna load the players scripted.

  • Let me just double click on it and open it in usual studio because we are gonna use visual studio for this And here I'm gonna keep it in the duck or a kn keep it from the duck.

  • So let's go over here.

  • What do we need in our player script?

  • What is that thing that we need?

  • Well, we always eat a couple of aerial variables, but before death, let me just acting class and a little bit down and move this like, this year, and there's going to be there's not gonna be process, but it's gonna be physics process.

  • We're gonna have a physics process and here above we're gonna inherit from Kino manic body.

  • So cinematic body to D instead of the node, We're going to have a private vector two, which is going to be our movement, and I'm going to call that won by default Vector to zero.

  • Next, we're gonna have a private float, which is going to be our remove underscore speed By default, I'm going to see its 400.

  • And these variables are self explanatory.

  • So moving, we're going to use for the movement speed you were going to use for the speed.

  • Now moving forward, we're gonna have a private float Gravity, which is gonna be equal to 20.

  • I know gravity is 8.9 point eight, but I don't care.

  • Just said it in 20.

  • Breaking the laws of physics over here, and we're also going to have a private flow that's going to be our jump underscore for spy default.

  • I'm going to say negative 900.

  • We're gonna have here also a private vector two, which is going to be up directions up.

  • The I r.

  • Is equal to vector two up like this, and basically, that's that later on, we will have for animation here we will have a private enemy.

  • That's pride, which I'm gonna call animation.

  • But that will come.

  • Don't worry about that now, inside of the player movement, which is something that we didn't create.

  • So here clear movement like this and inside of the player movement is where we're going to detect the input.

  • But first of all, let me just format this and call the player movement inside of the physics process.

  • So this is where I'm going to call it now, inside of the player moving.

  • What we're gonna do is we're going to detect it, our input.

  • So if in with that is G, so is depressed and or actually is action, so we're going to use an action.

  • So is action Press, and the action is going to be here in quotes.

  • And I'm going to call this one.

  • Move right.

  • So move right.

  • And as you can assume, I'm going to duplicate this and I'm going to say else if input is move left and also here, we're going to have a house.

  • So we're going to have all of these statements.

  • So what is gonna happen next?

  • What?

  • What you're gonna do well if We're moving, right?

  • Right.

  • We're gonna move the player, right?

  • If you're moving left, we're gonna move left.

  • But before that, we need to copy these that we need to go back here in our engine and project and project settings.

  • And here for the input map, I'm gonna paste move right.

  • I'm also going to pace Move left, and I'm also going to type here.

  • Jump.

  • So we're going to have jumped as well.

  • Now here for our move left or actually move right.

  • I'm going to click on the plus button and select a key and that he's going to be D So I click the on my keyboard that we do click.

  • Okay, quick out the plus button and key again in right arrow and click.

  • Okay, so now we have the right key as well.

  • Or the right arrow key.

  • Click on the plaza button and key.

  • And I'm going to click a now and look okay.

  • And Glick on the pause button for move left key and left Arrow, which is just a left.

  • I'm going to click Okay for the jump.

  • Look at it.

  • G space.

  • Okay.

  • And now we're good to go because Now you see here on our move, right?

  • We have the D and the right move left a and left and jump.

  • We have space, which means in our game, or when we press that button.

  • So here, for the right, when you pressed the or or right arrow, we're gonna move to the right side and here for the left.

  • If we press the a key or left, ever we're gonna move to the left.

  • And when we pressed these, we're going to jump.

  • So what's gonna happen here in our move?

  • Right is when we click on it, we're going to say Movement X is equal to move speed like this.

  • And when we press the left button, we're going to say movement ex.

  • He's equal to negative off move, speed, more speed.

  • So now we have we have the negative because the left side is the negative side.

  • And here we have the player movement.

  • I'm just going to tag it because at the bottom of our player movement, we're simply going to say, move and slide, which is a built in function from the cinematic body.

  • So here, simply, we're going to call movement, and we are good.

  • Todo now.

  • Of course, if I go back in our engine, commend me to test this out.

  • We are going to have some complications with you're going to see what you see now when I move, you see?

  • First of all, we don't have gravity.

  • Second, I'm I simply press the key once.

  • I'm not pressing it.

  • Currently.

  • I'm released it, but he's still moving.

  • You see, press once and he's moving to the right or the left side, depending on what key have I pressed?

  • So this is awkward.

  • As you can see, we don't want our player to move like this.

  • But maybe you want if you want to, you can leave the pool like this.

  • But if you don't in the elsewhere, we don't press anything.

  • Movement X is going to be equal to zero because here we're going to reset it.

  • If I go back now on actually to go back my engine cell command be.

  • If I go back in my engine, you see what's gonna happen.

  • I think this and now when I release that, he's going to stop when I move it, he is still there to use well, stopping when I move him, he's moving.

  • When I release it, he is stopping.

  • So that's why here in l statement, we need to set Moment X is equal to zero because if we don't want to move that, we need to reset the movement back now.

  • Also, in regards to our gravity here, we're going to say movement that why plus equals gravity, which is going to apply this gravity to our player Now, As you can see, it's gonna apply this gravity to the player.

  • And if I go back in our engine and command be, we are going to see that the player will fall.

  • Now, in order to fix that, we need to go back here in our game playing.

  • First of all, I'm going to right click here and add a child.

  • But I'm simply going to add a note duty and there's no to the I'm going to move it here.

  • There's going to be our BG parent and I'm going to duplicate one, and another one is going to be our ground parent.

  • Now the ground parent, I'm going to right click on it and change.

  • The type is going to be a static body so it's going to be a static body and I'm going to save it.

  • But let's go over here for the ground parent or actually for the BG pair in.

  • So let me just find our background.

  • So we have the sprites we have the player.

  • Here is our background.

  • So this is our back around, and I'm going to put this one as a child off the BG parent.

  • Now select the background and here I'm going to rename it to background one because we're gonna have multiple of these.

  • And let's go over here in the offset.

  • I'm going to click on this center so I don't want it to be centered for the transformer.

  • I'm going to say 00 for X and Y, and I'm going to duplicate it.

  • So now we have background, too.

  • And for the transform of background, too, for the y position, I'm going to say 700 or negative.

  • Excuse me.

  • 720 which is going to move the background over here.

  • As you can see now, how we're going to create our backgrounds is that we are simply going to move them by.

  • We're going to move him if I select both of them and duplicate him.

  • So now we have background three.

  • And I'm not going to make it as a child.

  • Some more with over here.

  • So we have back around three and background for If I go over here for the transform on the X axis for both of them, I'm going to say 12.

  • 80 is gonna move them, as you can see right over here.

  • So 12 ladies gonna move over here, duplicate them again.

  • So now we have five and six.

  • So copy these.

  • And 12 30 12 Lady, How much is that?

  • I'm not good in that.

  • So yeah, I have no idea about Mansell.

  • 12 80 plus 12.

  • 80.

  • That's +2560 So here, I'm going to say to five 60 as you can see right here and I get duplicate him, get a duplicate, and we're gonna have seven and eight.

  • So for these, we also need to add 12.

  • 80.

  • So how much is that?

  • So 12.

  • 80.

  • So let me just calculate that's 12 838 83,004 0 So the re paid 40 Let's go over here.

  • Do the same thing for these.

  • You get the point.

  • This is what you need to do.

  • So let me just move the 10 over here.

  • And so, like, the 10 and nine adds 12 80.

  • So let me see here.

  • 12.

  • 85,000.

  • 5000 and 120.

  • And this is enough off course you're going to do the same thing for the right side as well.

  • So I'm gonna duplicate here back around 12 Let me just moved down.

  • So now we have here.

  • No, not as Children of background 10.

  • So a girl needs to go over here, so select these two.

  • And now these are going to go on the negative.

  • 12.

  • You get the point.

  • So do that up too.

  • Negative.

  • So up to negative 5000 120.

  • And we're gonna do the same thing for our brown.

  • So here for the ground parent.

  • I'm going to select the ground, put it over here.

  • So there's going to be our ground one like this, and let me just offset it.

  • So I'm not gonna have set it on unsent.

  • Er it.

  • So to say so.

  • We uncensored the ground and the first ground.

  • I'm going to position at zero here.

  • And why is gonna be six five to?

  • So this is going to be for our first ground duplicated.

  • Move the ground over here and not like this over here selected.

  • And I'm gonna hold shift.

  • You put it right next to the other one.

  • So select the ground.

  • And this one, let me just select here.

  • The Y is going to be 652 and the ex is going to be 450 as you can see.

  • So 450 I'm gonna do that for another ground.

  • So let's go here for 150.

  • That's 900.

  • We have the grounds here.

  • Currently, we are going to have the grounds all over where the backgrounds, our I'm just gonna test the player's movement.

  • So I'm gonna test a playroom, and then I'm going to pause the video form all of these grounds, and then you're going to see what we have.

  • But before that's like the ground parent, right, click and add a child build.

  • And we're going to adhere a collision shape because we need to do that for the collision shape.

  • I'm gonna go here in select are rectangular shape and it's right here.

  • So what I need to do with the collision shape is resize it a little bit.

  • Dig the collision shape and position it.

  • Or here and let me just resize it so that it fits the grounds and we can land on it.

  • So if I command be now, command be now we stand on the ground.

  • You see, we stand on the ground, we can move.

  • As you can see, I still cannot jump.

  • Will do that study from the next video.

  • Because I wanted to create these grounds, I wanted to create the backgrounds.

  • And now we are moving with the player.

  • And now I am going to pause the video for all the girls and the backgrounds and come back so you can copy a basis or simply Donald a complete project Copy and faces holdback.

  • Be back in a moment.

  • Oh guy, I am back.

  • And as you can see what I did, I simply duplicated these backgrounds.

  • And then I repositioned my duplicated the grounds in position.

  • So the difference between the grounds if I take the ground one you see, it's at Expositions Europe.

  • Why position will be the same.

  • So 652.

  • That's for every single ground.

  • So don't touch the Y for the exes.

  • You can see the position for the 1st 1 is x zero.

  • The next one is 450 which means every next one is it 450 units to the left or to the right side, as you can see.

  • So when I move these on the left side so this one's gonna be 4 50 Next one is going to be 900 because 4 50 plus 450 plus 459 100.

  • So now take 900 add to it 450 which is 1350.

  • So add again 1 450 That's 1800 son.

  • And so for you get the point.

  • This is to the right side to the left side.

  • The negative one is the same numbers, but only negative.

  • So let me just find here this ground.

  • I believe so.

  • From ground 16 it's negative.

  • 450 than ground 17.

  • It's negative.

  • 900 than 80 negative 1350 You get the point.

  • So you're going to do this on your own tip?

  • A tedious for you to watch me to create all of this.

  • It's not fun, but this is part of game development, so you need to do it and the same thing for our backgrounds.

  • So if you take a look at your the first background, so both of these are at zero for the X Now, for the why this one is at negative 727 above one and every background that's above you.

  • See, we have two of these are the one that's up.

  • It's at why position negative 720 on Lee Exposition would change and the exposition will change for 1000 or 12 80.

  • So 1280.

  • So, for example, we have back around 10 If we want to add the next one to it, then it will be at X 12 80 then the next one is an ex 12 80 multiplies by two than by three.

  • You get the point.

  • Just add to it, though that value, and it'll position it right next to each other.

  • I also added this moon just so in as little bit that our game looks nice.

  • So yeah, nothing in particular will not change our game.

  • Our game can function without it.

  • But basically, yeah, this is this is setting up our level and creating players moving.

  • So, starting for the next video, we're gonna animate the player, make him jump.

  • So we'll see that What is cracking people?

  • In the previous year, we started our TV platform variation game and we created our level and we create the movement of the player.

  • But we didn't animate the player and we didn't make it jump.

  • So let's take a look at how we can do that.

  • So I have the player over here.

  • And in order to animate him, we need to get this component of this node.

  • You see animation because this is his animation.

  • And in order to do that, we need to go back here, and I already have a reference to it, as you can see.

  • But we need to get the real reference inside off the ready function.

  • So I need to see here.

  • Animation is equal to get no and not get note.

  • The note type is animated sprites.

  • You see here.

  • This is the type of the known enemy.

  • That's right.

  • And how do I know that if I go over here, however over it, you see, the type is animated Sprite, and now we need to provide the name of the know that we want to get.

  • So what is the name of it?

  • It's animation like this.

  • And let me just command be here to remove these.

  • So yeah, we also need to use the jump force.

  • And this right here will be room to room like this.

  • I don't know anyways is in port.

  • So we have here that animated sprites, and we get it here from the animation.

  • What I'm gonna do is go below the player movement, and here I'm going to create a void function is gonna animate our player.

  • And I'm going to call this one enemy movement, which takes two bullion parameters.

  • One is gonna be bull moving and another one is gonna be bull move right?

  • And why do we need this?

  • We will see in a second.

  • First of all, if we're moving so here, if moving, not right.

  • But it's moving.

  • Moving.

  • Come on.

  • Finally.

  • So if we are moving, then simply We're going to call animation, not play.

  • And we're going to play the walk.

  • Animation?

  • How do I know it's walk?

  • Well, if I go back here, you see, I have two animations walk and idle, as you can see over here, I have selected Walk.

  • Now I have idle if you want them to play.

  • So if you want to play one of them if I want to play the walks obliquely or called plate and call walk There you go.

  • Simple as that.

  • And here else, if we are not moving so else, if we're not moving simply, we're going to go and call here either, which is going to play the idol animation.

  • No, we are going to call this inside over here.

  • So let me just take this.

  • So here, when we're moving, you see, we're moving to the right, which means he are going to say True for moving and true.

  • Moving to the right side, As you can see.

  • Move right.

  • We have hair moved right, and here are moving to the left.

  • So here to say true for moving and falls because we're moving to the left side.

  • Move right here is false.

  • And here when we stop moving, we can simply say falls here and here.

  • We can save your tour falls.

  • It doesn't matter because we will see in a second.

  • But I want to demonstrate you one thing.

  • So if we go back over here and I hit command, be to play our game, which is going to run it?

  • Notice now, when I start moving, you see, he's animated.

  • Everything is cool.

  • This is totally normal, right?

  • Well wrong.

  • Because now, if I go to the left side, you seize moving backwards.

  • Except if you want to have this kind of functionality where player is moving backwards for I don't know what reason because I don't know your weird.

  • So yeah.

  • Anyways, you see if I click or hold command D or commanding just the or a or left there are right there are what's wrong with you?

  • See, he's moving, he's being animated.

  • But when he goes to the left side, he's not facing that side.

  • That's why I added this right here.

  • Move right.

  • Why?

  • Well, because if we are moving or here So when we are moving, I'm going to also check if move right.

  • So if we're moving to the right side else if we're moving to the left side Because if we are moving to the right, I need to go back here in chemistry that for you notice where the player is facing.

  • He is currently looking to the right side.

  • If I select the animation, which is our animated sprites and go over here in the inspector in front of properties You see, here I have something called flip agent flip V.

  • Hey, age is for horizontally is for vertical.

  • If I check this on for ages, he's gonna flip it and he's going to start looking to the left side, as you can see.

  • Flip it again.

  • He's looking to the right side.

  • Flip it again, left side.

  • You see what I mean?

  • So when we flip it and by default, as you can see how this sprite is created, he is facing the right side.

  • So when we don't flip it, he's gonna face the right side.

  • Which means over here we're going to call animation.

  • Flip age is false, because when we don't flip it, he's looking the right side.

  • And here else, if we're moving to the left side.

  • We need to flip it because as again, I said that by default This sprite is looking to the right side how it's created.

  • So if we try to move to the left, we need to flip it.

  • If I go back now and command be, do run our game.

  • You will see now when I go to the right, he is facing the right side, which is okay.

  • We're not flipping him.

  • But if we go to the left, a dungeon you see Ban?

  • He is flipping from the ah, you see, He is flipping, you know, flipping.

  • Anyways, I don't want to know you even though you're annoyed.

  • But you're here to learn.

  • So when we go to the right side now everything is cool.

  • We're not clipping him.

  • He's facing the right side.

  • If we go to the left, he is also being born.

  • He's flipped and looking to the left side.

  • Which brings me back here in our else you see here in the l statement when we stopped moving.

  • So hear this.

  • These two are for movement.

  • So if we move to the right side, true is for movement and true.

  • We're moving to the right.

  • If we're moving to the left so move, It is true.

  • So we're moving and here falls because we're we are moving to the left side.

  • But in the l statement, we're not moving.

  • So here we can say false, or we need to say falls because we're not moving.

  • And here we can see how your true or false and notice if I go back here and not over here but command, be over here, you will notice that nothing will happen.

  • I can move.

  • You see, he's moving and everything is fun.

  • If I stop the movement, he is facing the side where I have stopped moving.

  • So if I'm holding a key and I release it, he's facing the left.

  • And this is where he's gonna face when when I release the button.

  • Because if you go over here in our animation or enemy movement on Lee, if we're moving, we are going to flip him else.

  • If we're not moving, you're not gonna flip him.

  • And that is basically what we are doing here.

  • And this is how weekend this is, how we can determine.

  • I want to move when not to move and when to flip the character.

  • So moving forward, what is the next step to do now we need to jump and in order to jump we have a built in function from our cinematic body to d So this bad boy over here.

  • So if I go here right above our move and slide and moving slide is also a function that we simply provide.

  • So we call it it's built in, indicate a Matic body which will move into the direction where we provided and we provided movement here.

  • Then we know we are getting the movement over here.

  • So we pressed the right arrow key or the geeky were going to say Movement X is equal to move speed.

  • If we press the a key or the left arrow moves, speed is negative.

  • So we're moving to the left or to the right if we don't press moving X zero.

  • But here, I'm going to test if is on floor.

  • So this is a built in function.

  • It will tell us if we are on the floor.

  • And if that is the case, if our input that is key, just so, his action just pressed and that action is going to be jumped.

  • And if you remember in the first video, we said the jump to be equal to space.

  • So when we press space on our keyboard, we're going to jump.

  • But notice here.

  • So what is the next thing to do?

  • We need to see movement.

  • That why is gonna be equal to jump force.

  • Simple is that you see moment.

  • Why is equal to jump force If I go back and in our game command be Let's test it out and see if it actually works.

  • So command be if I jump, Nothing is working What is wrong with teacher?

  • You're crazy.

  • What a gunnery comes out.

  • Calm down then I'm pressing space, but it is not working.

  • So what is the issue you see here?

  • If I go back, you we have to jump.

  • And just to be 100% sure that I added the jumps on a map Here it is.

  • So we have the jump is space.

  • So yeah, everything was clear But it's not working.

  • Why?

  • Well, because you see here Moving slide We need to tell And if I hover over you see, I don't know if you can see the explanation you see here we have movement slide which takes a Vectra truly near velocity.

  • But it also takes a vector to floor normal.

  • What does that mean?

  • We need to tell it.

  • Where is the floor?

  • We know that going down so in Godot engine when we go down.

  • And if I dig here, My highlight tools highlight Going down and come on.

  • Highlight.

  • So this is the coordinate system.

  • This is the Y Axis, this is the X axis.

  • Plus is over here.

  • Negatives over here for the X but for the wine, negative is up.

  • Plus is down.

  • So when we go down, we're going positive.

  • We're going.

  • Plus, which means we need to tell in which direction is the floor.

  • And in order to tell that we have this right here, up direction, you see up direction because I'm saying up because this is a short cut for writing this new vector 20 for the X one for the Weiss.

  • And this is that short cut.

  • So if I see here, Vector two up is the same thing as if I rode Vector 20 for X one for device.

  • So, yeah, I need to get that out of the way.

  • But here, we need to provide that.

  • So we need to say here, up our eyes up the r I, which essentially will have a positive value, which means we're going down.

  • So now it will inform our cinematic body that down is the floor.

  • So if I go back now here and command me to run our game, let's see if the floor will be detected.

  • Space ways you get the point.

  • You see now knows where is the floor or the ground.

  • Because we told it, it's down, it's below us.

  • But we also have one more issue.

  • I'm gonna go here and I'm going to say G that prints, which is good, though for friends and he hasn't been to see the value is like this.

  • I'm going to say, plus movement.

  • Now, this movement over here is our movement.

  • You see, it's our movement over here that we are adding to it.

  • You see over this everything here that we're adding, But I want to show you one thing.

  • If I go back here in our engine and command, be noticed, what's gonna happen in the output we are going to print.

  • So let's go here.

  • In the output, you see, the value keeps increasing even though we're just standing on the ground to see I'm just standing.

  • If I jump, you see, the value is at the value that we provide.

  • But then it starts increasing, and we don't want that.

  • Some just gonna close this.

  • You see, we don't want that.

  • It's increasing even though it's not gonna hurt our game.

  • But maybe you will need it for something else where it will hurt your game if you have it like this.

  • So in order to fix it, we need to get simply say, here, movement is equal to move in, slide and here provide well, simply moving.

  • So everything else is gonna be the same.

  • Except here.

  • We're going to see movement is equal to move and slide and well up, that is that.

  • So if I go back now here in command, be so commend me to run the game notice now what's gonna happen here in the output we're standing, you see, we're standing, but the output is if I clear it, you see the output zero.

  • If I jump, we go up to negative 90 or 8800.

  • How much we set, and then it's gonna go back down again.

  • You see, if I go over here, let me just find where we jumped.

  • Where did we jump?

  • Here it is.

  • So we jumped.

  • So the valley was negative.

  • 900 Then it fell down because they're subtracting gravity.

  • As you can see over here, we're actually adding rabbit, you see, plus equals gravity.

  • Then we move down.

  • But then when we land on the floor, you see the movement value starts to get +0000 And we don't want that.

  • Even though, as I already said, this will not hurt our game, the previous one where we added the values.

  • But I just wanted to show you that in case you create some game on your own, use this or you use this code that I provided over here, and then you have issues.

  • So this is how you will know what the issue is.

  • And basically, this is how we can enemy and move our player.

  • And starting from the next video, we will probably have the camera so programmed movement of the camera.

  • Then we will add enemies and, yeah, wrapping up our game.

  • If you want to learn motorbike dough, I have that you might get Development Academy.

  • Hopefully by now.

  • I hope I have also Blender in and Game Maker and I'm working on Monreal If I don't have no really click on the link below, and I probably have a month trial.

  • So I have one month trial for $2.

  • You can try the academy out for $2.

  • Click on the link below and you can learn for one month for $2 like, Yeah, so yeah, I will see you guys in another Waas cracking people back out again with R two d platformer game.

  • So in the previous video, we programmed the player jump, and we also programmed animations.

  • Now we're gonna make the camera followed player, because if I hit the play button, command me to run the game, we are going to see that while our player can get outside of this screen and this is not what we want the camera to follow him.

  • That simple.

  • So, uh, let's take a look at how we can do that, By the way, if you want to try out my academy, you can do that.

  • Will be in the description below.

  • Tried out for one month for two bucks.

  • And if you don't want to invest two bucks, then Well, yeah.

  • Good luck learning game development.

  • So, uh, yeah.

  • Anyway, he's let me just go back over here.

  • Why can't I move this element down?

  • So you know I can.

  • So if I'm going to the game played, this is what we have.

  • This is our seeing this right over here.

  • And let me just draw said I can show you what I mean.

  • So this over here, this is our scene.

  • I'm not sure if you can see these lines, but it's not important.

  • But that is what we see.

  • And if I go back over here and let me just fold all of this in the game playing right book and a child know that we have the camera to D.

  • I'm going to call this bad boy main camp and this main camera Let me just go over here in the transformer off it.

  • And the position for it is going to be 640 by 360 because half off the width and the height of our screen should weaken position at the center.

  • But even though we have the camera, if I command me to run our game, we're still gonna go out of the screen, As you can see already.

  • So how can we make the camera follow the player?

  • First of all, what I'm gonna do is I'm going to click on the camera and we're gonna create a script.

  • So let me just go over here the scripts and right click and greet a new C charms script that I'm going to call that one camera, follow some things go here, camera camera follow.

  • And I want to get to create.

  • And, of course, like the main camera.

  • Go over here at the bottom and on the scripts here where it's empty.

  • Click here to load it and we're gonna live from scripts in camera.

  • Follow well up.

  • Let me just double click this bad boy and opening this inn issue studio.

  • Okay, so just act this and let's go here.

  • So what do we need?

  • Everything or the magic is going to happen in our override.

  • Let me just do this.

  • Said I can format this correctly, and we're going to inherit from note duty instead of the note only.

  • So no duty.

  • The next thing that we need to do is we need to get or create a private no duty for our players, something to call this one player target.

  • And while we are going to use it to get the player now, also here, we're going to have a public pool player died because when we die, we don't want the camera to follow the player.

  • And here, in our ready function, we are going to say here, Player target is equal to you.

  • But first we need to get the parents.

  • We need to see your get parents, because if we just use get no, we cannot use this.

  • So here makes it get No, didn't mean to be note to D like this.

  • And with the college player, I cannot just say this.

  • I cannot just say get known duty because the player is not a child off the camera get node.

  • So when you call get notes on a node or on a game object, it will try to get the note that is a child of it.

  • That's why we need to get the parent and the parent is the gambling.

  • So first we get the parent, then we get the child and let me just go over here in the process.

  • If the player has died, we're going to return now.

  • Return means simply exit out of the function because if we have died, if the player is that well, there is no need for us.

  • Thio There is a need for us.

  • Thio continue to follow him and besides that, we're going to kill the player, move him out of the game so that will not even be possible so below.

  • If the player is not that we're going to see your vector to temporary position is equal to the current position off our camera.

  • Next, we're simply going to say separate position Or actually, we don't even need to do this.

  • We are simply going to say temporary position is equal to player target.

  • So player target that get the positions were going to get the position from the player target than simply were going to say.

  • Position of the camera is equal to tempt and this is how we are going to follow it.

  • And even so, we can simply do this.

  • So, like this, we don't even need this vector to, so we can simply say position is equal to player Target.

  • Get the position.

  • So if I go back here in my engine, command me to run it, we're going to notice.

  • Now the camera's gonna follow our player, but that is not the case.

  • And I told you the camera's gonna fall apart.

  • What is the issue now?

  • Well, the issue is we need to selling the main camera and we need to go over here.

  • Let me just find where it says so.

  • Position, skill, offset.

  • Here it iss inside of the camera to D.

  • So we have the offset.

  • We have the ink and rotating zoom.

  • We have something here that is called current.

  • Let me just find it.

  • Here it is current.

  • This needs to be checked.

  • So when you check that check box, that means that the current camera or what we currently see will be the main cameras.

  • If I command be to run the game now, well known is that the camera now is following the players.

  • If I moved to the left, you see the camera is following the player.

  • If I drop the cameras following the player, if I go back over here again, the camera is following.

  • The player, as you can see, is you know, we And now we have the camera following the player and I want to be the one to recess is like this.

  • So what is the next step to do while the next step to do is we are going to at our monsters in our game, and then we are going to start spotting them in our game and all of the good stuff.

  • Anyways, fire here for mr dot com.

  • If you want to try out my game developed academy for one month, you can do that.

  • Two bucks on Lee from that link will be description below.

  • And, uh, yeah, I will see you guys in a video.

  • Wassup people far here dot com.

  • And in the previous video, we have the camera following the players.

  • So what is the next step to do?

  • The next step is to create enemies and put them in our game.

  • So let us see how we can do that.

  • But if you want to try my game if you were trying to get it.

  • If you want to try out my name to get me So now I have it right.

  • You can do that for two bucks Lingling description.

  • Look.

  • So what we can do now is here.

  • We're gonna click on the plus bottom.

  • So this is going to be our empty seem.

  • And this is where we're going to create are zombies?

  • No, let me just double click on this note scene.

  • And I'm going to rename this one to read Zombie, because first, we're going to have the reds on me now.

  • Well, actually, the green one, whichever one you prefer.

  • But what is the issue here is that we need to change.

  • So I'm gonna right click, and I'm going to change the type off this note because it is going to be a king a Matic body.

  • So yeah, cinematic body and I went to save that one here in the scene's folder, almost looking directly content And have the child is going to be our animated sprite.

  • So click on the animated Sprite and double click on it.

  • And I'm going to call this one animation because we're going to need this bad boy and the selecting the animated Sprite.

  • Let me just clear everything here going into the animation.

  • So clicking over hear clicking here on your frames were going to create a new frame.

  • This is going to be our walk animation and this is the green zombie.

  • So let's go over here and in the enemy's for the sprites We have the zombie green select all these images so all the images and put them over here So if I zoom on our zombie and click here to play, you will see now the zombies playing.

  • But I'm as 12 frames to that he plays a bit faster because I believe 12 frames is okay.

  • Yeah, 12 frames is okay.

  • You can pump it up if you believe it's not okay.

  • So, yeah, that's up to you.

  • I'm gonna select the green zombie game object and go here.

  • Add know that I'm at a collision shape duty now for the collision shape to do, we need to select here a shape so it's going to be a rectangular one, and I'm going to simply move this over here in the middle and resize it.

  • Someone with a little bit more in the middle of something like this and the zombies animation is confusing me, Sonny.

  • Uncheck it so that it doesn't play.

  • And now I can simply resize this dude And while we are good to go So this is going to be our greens on.

  • This is everything we need to do for him.

  • If I go over here in our scenes, I'm going to duplicate the green zombie and I'm going to call this one Red.

  • So you're going to have a Redd's on being to duplicate the green zombie again, and I'm going to call this one ghost.

  • So select here, the red zombie in double click here.

  • And I'm going to change this one to read Zombie and selecting here the animation for the springtime.

  • We disliked all these frames or actually simply going to delete all of this and create a new animation for the walk and go simply here inside off our folder and select all the animations for the Red Zombie and simply put them here.

  • That's all we need to do.

  • Everything else is going to be the same and doing the same thing for the ghosts So here it is. 00:43:

What is up, guys, Back out again with another video tutorial.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

A2 初級

戈多遊戲引擎教程--製作一款2D平臺遊戲 (Godot Game Engine Tutorial - Make a 2D Platformer Game)

  • 8 1
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字