Make A Game Like Pokemon in Unity | #1 - Introduction and Tile Based Movement

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

this is godlike, thanks.

👍︎︎ 1 👤︎︎ u/JFA_89 📅︎︎ May 07 2021 🗫︎ replies
Captions
everyone in this tutorial series will create a game like Pokemon in here D so let's look at what we're gonna make so we have diabase moment for our player just like in Pokemon and we have collisions so if I try to walk through this house I will be blocked and we also have a simple dialogue system so if I try to walk through the grass I will encounter a wild Pokemon so if he's a like a tack we will see the list of the attacks our Pokemon has and each attack has a PP and a tight so when I attack the HP of the wild Pokemon will decrease and it will attack back so since for the Souris level 7 and Charmander is level 3 Barbasol attack will cause much more damage so why let that mean the white Pokemon fainted and we go back to our scene and we can move around like before the pokemons are architected by using scriptable objects so we have a very flexible system making easily add new pokemons and update existing ones and even the moves are architected by using scriptable objects so the point is you try to create the game by using a good game development practices so before we start please consider subscribing to my channel that'll motivate me to do more of these videos so let's get started without any further ado okay so I'll create a new project make sure to select truly okay so first we need to import the sprites that we are going to use in our game so I'm going to use this 16 by 16 tiles it from open game art I have already downloaded it let's bring that into unity this create a folder called art or organizing and just drag and drop speights into the folder ok so we have many different spreadsheets in this back so we need another spreadsheet that contains some tiles from Pokemon so let's import that ok that's also imported so now since you use in pixel art you need to apply some specific settings to all our sprites so select all our sprites and in the inspector change the pixel per unit to 16 this is because we know that all our sprites are 16 by 16 pixels and change the filter mode to point and compression none these two settings will make sure that a big slab looks good otherwise it's going to look glory I hit apply okay so now let's paint some tiles in our scene so that we can get that reference when we implement a file-based moment so first we need to break a sprite sheet into individual sprites so in the inspector change the sprite mode you multiple and hit apply ok so now go to sprite editor you can slice choose goodbye cell size and change the pixel size to 16 by 16 okay so now our tile set is broken into individual tiles hit apply okay so now if we look inside the tile set you can see multiple tiles next let's create a tile map to paint our tiles we'll go to to the objects and select tile map I'll rename the timer to background so paint on a tile map we need to create something called a time palettes so first open the Thai palette window to window Judy and I'll palette create new palette I'll call it background you need to choose a folder to save the sense get new folder called tiles next drag and drop this tiles set into the type and again I'll choose a tiles folder okay so now we can select a tile and paint on our tile map so I'm going to just choose this style as my background tile and use the box to paint some background lights okay so now really create the player so first we need to break the character sprite sheet just like we did for the tile set so the inspector change the sprite mode to multiple and it apply and inspite redditor you can slice choose grid by cell size and this time the pixel size is going to be 16 by 32 okay so the character sprites has been split correctly so hit apply next drag the first right into our scene so this creates a game object I will rename the game object to player but our player is not actually visible so this is because the player is under the background so we can use sorting layers to tell unity to always show player in front of the background so let's create some sorting layers I'll add a layer called background and another one called clear and I'll assign the player sprite to play a sorting layer and the background tile map to background sorting layer now we can see our player so one important thing is that the player layer should be below the bathroom level if you put the player layer above it the player has gone behind the background so it just makes sure that the player terror is lower the background layer okay so now let's implement moment so in Pokemon the movement is style based which means the player will always move from one type to another so for example let's change the players position to 0.5 now the player is in the center of type so if I press the right key player will move to the center of this tile it can't move to a position that is bit in between these two bags so since we know each tile is one unit we can just add one to its x value okay so now it's in the center of next side this is how we are going to implement movement let's make a script called player controller and just create folders to organize things open the script admissions video so in the player controller we need a public variable for the movement speed we need another variable to check if the player is moving let's create a boolean variable now in the update function if the player is not moving then we'll check for input and try to move the player so let's get the input so I stole the input and available and by the way this moving doesn't have to be public because we don't want to be able to change that from the instructor so now if the input is not zero people cached the target position to which the player should move so the type of position will be the current position of the player plus the input since we're using get axis straw the input will always be 1 or minus 1 so if I was pressing the right key the horizontal input will be 1 and if I was pressing the left key the horizontal input will be minus 1 so we just have to add the input into our current position to get the target position okay so now we need to write a column no the player from current position to the target position so if you have never used a co routine before it's a special type of function which has ienumerator assets return type so it's used to do something over a period of time so in this case we want to move the player from its current position to its start a position over a period of time so let me explain how this core routine works so when this code clean is first called it will check if the difference between the target position and the players current position is greater than a very small value so if there is actually a difference between both positions then we will use the move towards function to move the player towards the target position by a very small amount so after that he'll return on will be executed this will stop the execution of the cold game and resume it in the next update function ok so that's how he'll return statements work inside a core routine so in the next update function execution will resume from here so once again it will check if the difference between the two positions are greater than a small value and again it will move the players current position by a small amount so this will keep repeating till the current position of the player and the target position are really close and after that this condition will be false and will come out of the loop and outside the loop we will just set the players current position to the target position okay so that's how this cow routine works so one more thing I want to do is at the start of the core routine I'm going to set is moving to true and at the end I'll set it to false ok so now we need to call the quality from the update function call a core routine we use the start coding function we'll pass out our position okay so now let's assign the script to our player we will set the speed as file and test the game okay so you can see that the player is moving from one tile to another very smoothly so one thing I want to do is I want to remove the diagonal moment because in Pokemon we can't move diagonally so here I say if input dot X is not equal to zero then just set the input dot PI equal to 0 so only one of these can be nonzero at a time and the play won't move by me that's just the game now ok so we have removed diagonal moments so I'm going to stop the video here and in the next video we will look at how to implement animations few things video was helpful please make sure hit that subscribe button and I'll see you in the next video
Info
Channel: Game Dev Experiments
Views: 91,945
Rating: undefined out of 5
Keywords: make a game like pokemon in unity, how to make a game like pokemon in unity, make pokemon in unity, make pokemon game in unity, how to make pokemon game in unity, make a pokemon game in unity, unity pokemon game tutorial, tile based movement in unity, grid based movement in unity
Id: _Pm16a18zy8
Channel Id: undefined
Length: 14min 2sec (842 seconds)
Published: Sun May 31 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.