Create a game like Crossy Road using Unity & PlayMaker | Vaddadi Karthik | Skillshare

Create a game like Crossy Road using Unity & PlayMaker

Vaddadi Karthik

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
9 Lessons (56m)
    • 1. 01 Overview

      3:48
    • 2. 02 FSMs

      2:50
    • 3. 03 Player Movement

      11:05
    • 4. 04 Jumping on Logs

      9:22
    • 5. 05 Collecting Points

      6:18
    • 6. 06 Death

      6:46
    • 7. 06.1 Restarting the game

      1:59
    • 8. 07 UI and Score

      7:16
    • 9. 08 GameOver

      6:31

About This Class

This course is an introduction to prototyping the game mechanics of Crossy Road on Unity using PlayMaker. We will be looking at how to script movement, game events, camera and everything necessary to create a basic prototype of the game.

You are expected to have basic familiarity with Unity : like creating objects, moving them around and knowledge about the different object components. This project will be available for download to study and practice the use of PlayMaker.

This course is basically for:

  • Beginner game designers who are looking forward to make games with ease using PlayMaker in Unity
  • People who want to learn game development through recreating games

Transcripts

1. 01 Overview: Welcome to this course on the introduction off Playmaker and how to create Across the Road prototype on Unity using Playmaker. My name is Codec on in the game developer from India, so this course will be off two main parts. The 1st 1 is how to get started with playmaker understanding the framework of finite state machines, which we will be using to make our final game. The second and final part will be creating game mechanics off cross the road using these finance technicians. So this course is not an introduction to unity but an introduction to playmaker and how to use it to create cool games. The entire village product will be divided into scenes where you can practice the things you learned any chapter or episode that we will be going through now that I gave a basic idea off half discourse is going to be Let's take a peek on how the end result will be. So this is the gimmick After that will be controlling with W S and D case. So there are flash points on the map. Distribute it and you should not jump into the water so that ah, play wentai so we need to collect that particular point and last point is here. So dress of in conditions that we collected all the fresh point. So that is going to be the basic game that we're going to create. No, there are a lot off things going on in the background. So let me explain each one of them. The 1st 1 is the movement, the movement off the game character that is this chicken which we control by pressing W A S and D keys. That is the first thing that will be doing in our project. And the 2nd 1 is placing each and every prop and making it interact with the player. So coalition in direction using unity physics engine. It's the second thing that we'll be learning. And once we collide with water and in this example, let me show you what happens when we jump into the water, you know, and that particular condition that effect respond on Leven. The player is being hit by either water or vehicles. So that IHS one condition that we really need to set up that is going to be the next part. And after that we'll be focusing on G Y, which is the graphic user interface. But off this particular course, where were displaying the number of points that we collect as we co as well as hand to the player that pressing are would we start again? So these are some off the elements that we will be looking forward to learn in the scores. 2. 02 FSMs: What exactly is an F Isn't an f ism ISS a finite state machine? Now, as its name suggests, it is made up out off states and it is a machine, so it needs to function for a particular reason. So if ISM is basically a compliment in unity, which we will be adding through Playmaker, so let's take a look at what exactly if some stupid just taken example off a floater with force determined, start input output and finished. So the first date start with initial is the aphorism on, then send it to the input state. So in the end but state, let's say that we're making a game and it's a first person shooter. So in the input state, I need the player to click the most button. So this input state will give instructions whether to record the click or not, and if recorded, what do they do with it? So once the most button has been correct, it will transition to the output state, and it would shoot the bullet so it wait for then put at the first state, and even Julie will transition to the output state, where would to the blood we will get more familiar as we start making F ISMs in the upcoming lessons. So just understand that these marks is that we see in front of us are basically state in our systems and the instructions that we give inside these particular states article actions and all the arrows that are connecting these dates or boxes I called transitions or event. Now a transition can be self, or it can lead to another state. So if I say from the input state, if the player is not pressing anything, it would transition to the same state so it would loop and wait for the player to click. So there are two types of feminism's. One is an F isn't where it would completely come to an end. The second diver, Fauvism, is where it would keep on looking and would never come down, and it would function each and every time in the game, so knotted about effort. Since let's get into the practical aspect off how to build an efficient and added to a game object and use it to build game mechanics 3. 03 Player Movement: in this lesson as we completed tourist little framework off how playmaker functions like float at, Let's go ahead and implement some movement on our player. So as you have the project open, you can get a project window. And as you imported the package that is necessary for this course, you can find these scenes being important. So we need to double click on getting started so that we can get started with a single moment. So we'll go to player and got a playmaker and add our first Stepherson and we'll call this Jefferson movement. We go to the first date and let's call the state input where we take input from the player and will go to the action browser and type in input or that c for the categorical input. And they go forget kid down. That is the even off a key being pressed. So we want the wkd repressed. So I click on the Drop down and plus W or Playmaker to recognize the key that I want the players to be pressed. So a sending event, which say's no new, is trust, and here we click to add this transition to the state and we'll create a new state so that when repressed w it would transition from the state of the state. So this Quicken dry to the second state, which and Wolfman and we go to the action browser and we say and force and we go AdForce and double quick and it stays that our game object needs sound. Visit body company into all this click here and once I click, it would add this competent and we need the traditions to be fixed. And let's see the collision Detection, too, continues as the player would be moving throughout the game. So that's, uh is he values 200 on the vai value off 2 50 on the cell space and let's hit Plea. So country place W we continue that player jumps. No, we can see that the jump was very slow. Now, since crossword is a fast paced game, jumping doesn't seem to match the game space, so we need to use a boost and make the game a little more faster. We'll do that by quit a empty object and then rename this Teoh game manager and here we put all the effort since that are vital to the game. So we go to Playmaker on and our office in and call this time just and we go to the first state and that's a skill time. And here we are, Skilling the time by two so that the jump looks more decent. So we go back to the game and hit play now when I first told you play terms, but because after time this particular forces multiply, so we'll just divided by two. Make this one time we play and I'll make this 100. No Cyprus still with you, the tempest. Pretty decent. So that's exactly what we want. But you can see that if I would eat the player and if I had played sharp us in W. He should be jumping this way. But he's not jumping this way. Exempting there was the direction that is facing. But that's not exactly what we see in concert. If we strike up B, but it's up and jumps up. So how do we do that? That happens by validating the player two words in the direction that we want. So when w. Expressed, we'll create another state in between. That stays certain rotation and in this will set rotation off the player and we can see that the andl on why should be 1 80 So it's said that to the sub state. So when w. Expressed, we need this to situation first and we'll add a finished transition. And from that we need to add movement. So this would it to clean now. Friendless play. Now, if arrested w he should be jumping to its the pastor of Sea Access. Now that's happening. So now, since that is finished, let's take a look. And how can we fix double something if we go to add forest and at if in estate and connected math to in foot? And if I had play and if I tried oppressed, tell you twice quickly, you can see that I could double Jim. That's not what we want the player to do in our game Now. We can fix that by saying that whenever the player jumps, he cannot jump again until he hits the ground. Now we do that by recognising collision. Now collision is only for rich bodies, so we'll get 1/3 state which stays at movement, and here we open up the action rose here and we find collision serving in the collision, even action that we were good. And this particularly defines objects based on tags. So we go to the grown and game object, would be untied with this drop down and go for ground the attacks by clicking on an attack on. Then we can add all the tax that are required for the game. So just go back to the player. The ground is set the tag run. So I'll say the Cole attack should be grown and Ascender even finished on we. Then the collision is recorded. So now if I had played and if I had tried to press w quickly, I cannot do it. That's because we fixed the double jumping issue. So using the same kind of state, the the cod key persons for every single direction. So let me give an example off another direction, and you can do the rest of it. So this copy this action and placed it in the same state, and I'll go for a help us a. Two days on blue ISS. Fun and I say, is pressed. So good. Create, even click on this and we need another state something like this. So let's copy the state and paste it here. Another connect ace. Best to set rotation to on here. We need to change the tradition to nine to So you condone. See that over here Reading A to be left side off the blue Sewell This make it 90 and the movement state would be the same for each and every, uh, in direction. So now if I press play A, you can see that the player has turned to the left and jumped on the scene happens for it. W So that's how they used FS IMS to add movement to the player. Now, your task is to complete this efforts in and make sure that all the traditions are here. So I just showed you two different rotations. So I expect you to complete these two. So if I play once, I'm done with all the quotations, all the key purses. The gameplay would look something like this 4. 04 Jumping on Logs: no. As you remember from the course outline, we have this water crossing where we have to jump on logs and time. Oh, our players jumped 30 will, as these logs are pretty fast moving, So let's go ahead and go to less number two and click on landing on moving looks that unity and public. So we have only this segment. So since we already finished sitting out players movement, let's go ahead and create our first F ism for the stability own logs. So as you can see that we have a long here click on the log and you can see that we need the player to jump on the lot. So as we already implemented the movement, this hit W when the law comes. But you can see that the player just died. If I symbol on the law now, that's because the longest moving and the player is not moving along with the law. So how to fix that? We go to log and it's like the top must killed off all. So this is cute, too. It must be the same for you as well. So we gotta playmaker and and a quick F isn't for this particular que so Call this, said parent. Now I'll go the first date, and what we need is a player to jump on the log. And when the log is being collected with the player, the players should move along with the law. So if you're familiar with the unities parenting system, what parents do is is that when you turned a game object to another, the child object moves along with the parent object. So if I also I'll tell you an example off how it looks like so sure, I have this curable here. Just bring this cube over to the top. So this cube is my and object. And if I quit in a look, you and move this over here, if I sell it the Parent Cube and move this, you can see that the other Cuba's moving as well with respect to your current position and the rotation would go in the same as picked us well, so that's exactly what we're talking about Now. If I go back to this to this lot and let's say that when the player collects with this particular along tonight, we need to lock to set the parent after player as the law so that the player is pretty stable. One moving. So go to First state and say, coalition, Even once we had this collision event action, we go toe collision tag and tell this to player and send the even player on luck. So we will add the transition and add in the estate and connect us with Second State. And once the player is on the log, we need the law to be the parents. So search for set here in and I need the parent to be the winner, which is the cube to game optic. So we can dio another thing here that is still the collider. Whatever collided with the lock. So when the player is colliding, are creating the variable. Now this variable is going to be a game launch tape. I'll see this is the player. So whenever game politics with attack clear jumps upon the law and still it as a collider called Player and I'll sit the game on tick, the player on the parent should be the owner. So the owner is cute too, get Oh no and still with us, a medical log and said the parent to be the log. So if I hit Lee now and if I time my jump properly, you can see that the effect which waas which was there, is gone. So now what do we do whenever the player exits the law? We need to play to come back to the hierarchy. So we do that by reversing this. So this. Copy this particular human over to the second state and say on Collision Exit. So whenever the player exits the log, so I'll call this New England, leaving the lock so clear in the event and quit in the estate and collect this with this in a sit haven't no. What I'll do is specify game object and use drop down to select a player and I said, depend to none, as the players parent is the law after being jumped. So now we need the parent to be no Gail object, so he would return to the main Iraqi. So if I let's play and we'll, we'll keep a keeper track off what's happening in the hierarchy here. So if a John I can see that the players position changed, it's now in the cube to Iraqi if I jumped back, you can see that there is no child off the cube to the logic. So if I drag down and t the player is in the main Iraqi, so that's exactly what we need. So we go back to the lock to bring the cute too. So I finished this and returned to the first. So now, since we finished creating RFs, um, for the first law, you can copy this effort, Stan, and you can go to the other longs, and you can bring in the logs. If you want to place another law, you can delete these loves and you go to ass it more. Whose and river long. You just clicking back and you can see that it alliance alone and you can place it anybody you like and make sure that the jump IHS being single ized. But the placement after law, you can go to the Cube to and then paste your efforts in over here. So no sense this is already a love that has the office. Um, you can either do you live in queried beneficent for practicing this particular lesson that we have learned 5. 05 Collecting Points: river water one off. The motivation inside again when you don't have enough coins to unlock itself, pays off its character that you love you, prolong your play and sit on it for a few more house. Now you are thinking off adding points, our clients and side our game, which is kind of vital to the game. Now let's have let's make our game a little more interesting. Filing these points, I just get a project and open less Number three, which is collecting points to get started. So we have this particular segment along with the points entirely. So first half, I just riff you on what to do about this particular lesson. We're gonna involvement, and we can see that these points are being a part off the log. So I just need you to recognize that this point are the Children off the logs. That's why they are moving along with logs. So we go to us West, find and see what interaction that we can add to this. No, these are not something that the player likes to collide with, or we don't want these to be like hard objects way. Just need them to be collect collectibles so we'll be using is trigger from the box collider in point to Ritter's inside the Law. So just take this trigger. And once I got this good a playmaker and add the efforts in that adds functionality to this to the first thing that we do is is that these are pretty similar to collisions. But since these air triggers, we just typing trigger and we can see that we have a trigger event and what resist at it by double clicking. And they need the trigger to work nice. When a game object with Nikolai Tag Player enters into this vicinity. It would send an event that player and food and I quit uneven and end of the transition new ad in the estate that would say at point. So I'll connect clear, enter it to that point. And once I do that here we are dealing with variables. Now this is going to be our first Babel intact. The game, so available is value off something that we store, so it can be a simple number, which is an anti ager. Zero wonder three minus one minus two, it said. Well, it can be a tour false condition, which is a Boolean. It can be a decimal, which is afloat that is mainly used for force and variables like that. And it can be a position off a game, object or rotational scale. On these are a set off three different numbers instead of three different floats to be specific on. These are called back to three rebels so will not be covering directed three as off now. So once we add the second state, really just go on such for ent. And if it back down, we can go to Matt and see that we have an actionable into ad. So this double quicken and, uh, because we want the in teacher to be increased asked three. Collect the find so the antiques available will be points. So how did I get this global wise? I just created a global revel. You can create another global rewritable four points. But I said just you to use this phone as we already created one. So I'll just and one to this and first enter. So is that it no, really are also going to destroy this game Object after the player interested, So a list. Click here and you're to destroy, and we can see that there is an action for destroy Self. So just double quick died. And we don't need to conduct this Mac as this would end over here. So So we need to keep track off the variable with this point as a good available stuff. You can find it here, but we cannot. Well, bit as we click on it. So we have the section for global rebels. I just click on it and a new window will pop up. So just docket over here just to keep track off it. So I'll just hit play. Still, we are trying to jump on this political alive and they felt jump on it. We can see that the points variable is increased to one. So continue jumping. We can see that the point of being accumulated as we collect them. So that's exactly what we need are clear 6. 06 Death: So I've been playing our game for so many times now, and I tried to find some bugs, but I kind of I feel that that's not a challenge in this game that we created. What do you think about it? Which arm? And we collect points? Let it. It kind of feels a little dry and steal. Then I had a thought that struck, which actually makes sense. What if we jump into something wrong? Let's say the water around the logs or the vehicles on the world. So what we're talking about now let's play that. So let's get started and go toe play that which is a very vital thing in our game. So I'll go to play that and open up this scene. So we have a player and all the bagels. We have the entire scene almost, but we don't have descript ing that is done for the debt. So go ahead and go to player and a lot in your office. Um, and coldest debt. So what are they talking about when we talk about that is collision. So for our chicken, it can be two main reasons. As we taught us, it can be either droning and water or being hit by one of the cars that are smoothing on the word. So we're talking about collision severe target in the visit body. So this is pretty familiar to us, as we already dealt, but collision before when we were doing about logs. So we'll go ahead and open up the action browser and type of collision, and we'll choose the collision event. And we need to recognize some tugs that we are going to dio. So we have these three planes and we can see that the tag is already set to water. So we'll use that tank and recognize that whenever the player is being hit by water, he dies. So I just go back to FSO and Colli tag. I'll save water and I'll send it even that say, stick around. So I create a new state and a kind of this to the second state. So here we are, looking at giving some feedback, just not destroying the player directly. That would be something funny that would not let the player who is playing the game know that No, what happened? So we just need to give some sort of freedom back now, I created this particle system immunity that, uh, I kind of feel is kind of okay ish for giving feedback to the player that the player died. So we'll use that particular ah, you know, particle system. So I would go to asset and particles and you can see that there is this water that so this drag it out and you can see that that iss the particular ah particle system I was talking about. So I just deleted until this is a game object. So we will go back to the second state and let's say we want to do to create this particular object. I never go to quit object. No, I'll choose. Choose Teoh Water that so you can actually drag water. That and that's into this game object. And then we have a spon find to be given. So we're looking at another action, which is get collision info, which actually takes the contact point off where the player exactly hit the ground. So that's pretty useful. Let's take that and store it in a find variable, and we're doing that's first civil drag this up and then great object and then we don't. We don't need this. They need the position off the spawn point, which would be point. So this checkpoint here and close this of what else do we want to do is destroy that player ? Came objects. So we do that by using the destroy cells action which read it before for the points. Jefferson. So that's exactly what we need. So just hit play and see what happens. So I want to jump into the water so you can see that as soon as I jumped the player is deleted. But there is a particle system beings find before he died. So that's exactly what we need as a feedback off debt. So you can do the similar thing for the water as the last vehicles. So we go ahead and see what exactly the vehicles are attacked. So the tag on the cars is finished so you can do a tank. As I guided you through this one, which is the collision event for the collide tag water, you can pretty much quit the debt office, um, for the vehicles. So once you've created that, it should look like almost the final game 7. 06.1 Restarting the game: Now let's hear that you wanted to test one of the features off your game and you're tired hitting the play button again. Allegan immunity. And it kind of takes time to, uh, for unity start again. So instead of that, you can do another thing, which can also be a game feature that is restarting the game inside the game. So you can do that. My going to the game manager and we can add an officer that would say we start so this will start game will be getting a key. And let's say we wanted the R key and we'll send the even to restart as soon as the player process the A p. But at a second state and this state, we would be restarting the level several press restart, and then we have this. So one more thing we can up stuff in our game is that we have a bug. So once you collected 23 points and failed, and then if you restart the game, you can see that the older points that you collected before you died still get counted, so that would be a bug. After adding this particular game, manager efforts. Um, So what we will do is we will set the end value off the points deceiver before restarting the level. So that put fix anybody. 8. 07 UI and Score: one of the most important forms off feedback in games ISS the game in the face where you track your progress. You keep up with the current condition, depending upon which you take decisions. Now this should be an accurate and quick real time. Updated feedback for that before anything we need a you I text inside are seen. So let's go and Teoh less number five you I and let's create a you I object, which is a text. So once we could created that you can see that a tiny text up here and let's let's just name this game object as points to the things that we need to be recognizing and showing back to the player is point. As for less a small hand that fizzing are, would we stand again? So if player gets stuck in the middle of the game, that would be a bad part on the developer. So we have this point created, And how does this make it kind of big and make it okay with upon size of 50 maybe, and teams that will flow Teoh overflow and kind of changed the text Teoh a number which is a river so this center this to the top left and just position it at a place very confortable. Further player too. Look at one text would be the text that defines what this number is and the other text would be the main text that shows the number. So let's duplicate this and I'll pull this to a little left and with the text two points. So to drag the points to there and this fun, it's going to be a little new, which would be the set property action off playmaker. So just add a Nevison and I've called this Jefferson update points. So now we're looking at the turd form off variable, which is a string a string is available, which is basically a text. So what we need to do in this first state ISS, we need the text here to be changed. So playmaker has this wonderful feature where you kind of go to any competent and you can click and drag into the state. And when you leave it, your you kind of see this get property and set properly on script control. So what we need, what we're gonna understand from this is the good property would basically received that. So this is basically for access and said property is for complete access where you can even edit that particular competent. So we are going to edit this. We're going to modify this and say that this particular text is equals to the global variable, which is point so set property off the points text on the property is going to be the text . So we have ah, big middle over here. So press to and then I have text underneath this. So as you can see when I go to text, I can either control this string or the land. So the string iss what we need, so restrain. So we can still this in available. I call this text on the score points and I've had creative able and there's going to be every friend, so every frame is like real time. So once we do that, they're going to global's. And once we go to Global's, we can see that the points here is off type. And so what we're looking at here is a string. So how do we convert this? And teacher and a string iss through the end to string convert action. So Liniger allows you to convert different variable types. Two different favorable tax. So you go to convert into string, double quick on it, and we want the into Terrible because the group global very vocal point and we need to come with that into this text point so that would be available already inside that drop down. So this should be every frame as well, so we need to convert before setting that particular property. So I put it first. No, since I just created that that this hit play and see whether it will update that particular today. So I try to take the points and you can see that it is pretty much working already. So I collected the second point but failed, So it's pretty much updating. So it's working now. We need to also created fixed that would say, pressing our Would we start again Now that's pretty much simple. You just created a Y object text and then why don't want to want to come ready to the player, so that's basically it. So once decorated the you, I will be looking at the one condition which will be the final lesson in this course 9. 08 GameOver: now that we created each and every game mechanic, we will take a look at how, exactly we can convey the message that the player has won by collecting all the five points on the map. So we have a condition that stays. Once the player finishes collecting all the facts point, we will display this particular message, so displaying the message is complete feedback. So let's quit the gooey element. Let's first go into game over and go to canvass and create a u I. I know, and this panel is going to have a image that, too think that. And let's of the transparency off this panel to be it black final and then the image a little more fighter. Let's create a text inside the image, but days you want. Now let's make this a little more bigger. That's a 50. And I said the old floated overflow. Okay, that's kind of pretty big. So this the t A one of 35 would be good. So we have this panel ready for the player to be shown. So once we finish collecting all the five points, we want this panel to get activated. So we do that by currently disabling this and once we go into the game manager and open up and you have for some this new office, um would would contain the when conditions. So name It meant condition and I go to the first aid. And here we are looking at in Teacher and you can see here and logic that we can compare the in teacher that is in the game. So use Dad and it asks for which which anti Jewish should be compared. So we need global variable, which is point on. We needed to compare with five surface equal 25 I'll send a event. Colvin. So this created another state and conduct this win condition to the second state. And this is going to be every frame so that it takes every time. Whether the player is collected has collected five points. So we're going to stay too. And open up the action. Rather Onda we look at activate give up Now This game this activate game out it would be specifying a particular game of it. You're not activate the owner tell So I go to specify game I take on then the dragon. This panel that we just created. So this dragged into this and act raid recursive iss that it should activate or deactivate all Children. So we need the Children to be own as well. So that's basically it. So once we do that, we hit, play and see whether this is working so you can see that that particular panel has been activated. Once we collected all of the five points and you can see that winds have been updated in the user interface that we created. So that's basically it for the entire course. I wish that you understood it in every point. And I have completely, uh, provided all the documentation in in this particular scene where you can go toe any of his own, for that matter. And you can find explanations to each and every state as well. Us Jefferson. So if you wanted to learn about what happened in this particular efforts, um, you can see that there is an explanation given for each and every state. So I find that helpful when I am learning playmaker. So I'm just giving back that particular kind of learning in a moment where you can understand each and every thing that's going on inside the game, so you can even take a look at this one. The collision for the logs as well. That's the point that we pick up inside the game. So I hope you have. I learned the basics off using playmaker as well as you know, getting around with creating this amazing game as well as the years in the face and a lot more stuff.