Make a 2D Platformer Video Game with Unity and PlayMaker (no coding required) [Part 2] | Brandon Wu | Skillshare

Make a 2D Platformer Video Game with Unity and PlayMaker (no coding required) [Part 2]

Brandon Wu, Founder of Studio Pepwuper - a Game Studio

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
13 Lessons (1h 7m)
    • 1. 12 Platformer Intro

      1:33
    • 2. 13 Import art and create animations

      8:07
    • 3. 14 Floor Tiling, 2D collider and rigidbody

      6:23
    • 4. 15 Player Control Left and Right

      4:08
    • 5. 16 Jump

      2:06
    • 6. 17 Ground Check

      5:39
    • 7. 18 Player Facing Direction

      3:32
    • 8. 19 Animator Conditions and Transitions

      6:09
    • 9. 20 Idle to Walk Animation Based on Speed

      6:18
    • 10. 21 Jump Animation

      7:09
    • 11. 22 Fixed Angle

      0:52
    • 12. 23 Add Force, Set Velocity, Physics Materials

      9:00
    • 13. 24 Polygon and Edge Colliders

      5:39

About This Class

e0b25596

Note: This is part 2 in the series: Make a 2D Platformer Video Game with Unity and PlayMaker (no coding required). Find part 1 here, part 3 here and part 4 here

Teacher: @theBrandonWu

Now that Unity supports 2D games, we can make a game in one of my favorite genres – a 2D platformer! (Think Super Mario Bros. on the NES... ah those were the days!)

In this series, which is the perfect follow up from class 1 (I recommend you take at least the first 2 weeks of class 1), we’ll go over the basics of Unity 2D, sprites and animations, 2D physics, and all the controls you need to get a 2D platformer going.

And all of this without writing a line of code, thanks to the power of the awesome Unity plugin: PlayMaker!

The class at a glance:

  • Bite-sized, Easy to Follow Video Lessons
  • Self-Paced Online Class with Fellow Student and Teacher Support

Here’s what you’ll learn in this series (it's divided into 4 parts):

  • Part 1: Introduction to 2D space in Unity
  • Part 2: Introduction to our 2D platformed game and setting up player character
  • Part 3: Dealing with Camera – the easy setup vs the complex setup
  • Part 4: Setting up Enemies, HP, and Attack before we wrap up!

Who is This Class for?

This class is for beginners with a basic understanding of Unity and PlayMaker. If you’ve never used Unity or PlayMaker, you can start with this class first. Both courses are adult and kid-friendly! :)

What You Will Need

  • 7-10 hours of free time as we dive into the process of 2D game development. 
  • A modern PC / Mac with 3D graphic compatibility (if you bought your computer in the past 5 years, you should be good to go.)
  • A download and installation of the Unity3D game engine http://www.unity3d.com/. Don’t worry about the seemingly complicated interface, we will go over it in the class – piece of cake!

About Playmaker

  • Students will be provided a special student version of the popular Unity 3D ToolPlayMaker. This is the tool that enables us to create games without writing code. Thanks to Hutong Games, this special student version will include ALL actions in the tool (note: student version not for commercial use).
  • Commercial version of PlayMaker – we strongly recommend buying a license for PlayMaker. Although you can use the student version of PlayMaker for the class, the class is really designed with a commercial version and it allows the use of additional free add-ons and tools to make your game development life easier. It is one of our favorite #gamedev tools ever!

What Students are Saying About Brandon’s Classes

“Exactly what I needed to begin my journey into game development. I will DEFINITELY take ANY other classes taught by Brandon Wu! Thank you Brandon!!”
– Nicholas Mitchell

 

“Time and money well spent. I have no coding experience at all but thanks to this class I feel much more confident about game dev process. Thanks for this amazing class!”
– Sung Kim (Animator)

 

“Brandon Wu’s class was simply the most richest online educational experience I’ve ever had! So much content, so much detail, and so so much fun! I would recommend this class to anyone who has even the slightest of interest in how games are made. I’ve paid 50 times more for an online class, and this has been the best!”
– Brian Anderson

 

“Great class!! Enjoyed making the projects. The amount of information covered in 4 weeks, was just right. Instructor was knowledgeable and supportive.”
– Greg D.

Transcripts

1. 12 Platformer Intro: Now that we have some basic understanding of how to de works in unity and have some understanding of how it can control the animations, let's try to start creating a platformer game. So here I have a little character that we can use to enemy and control on. This is going to be the first step where we create his character, make sure the animations air in the in the game and then creates on basic controls. And I'm gonna show you how you can use some of the more advanced features in the animator to control the animation. Now the first thing you want to do is go to open dot commonly dot cc, and this is where you can download the open game or under, which is great. Fundo. What a lot of great part and music that you can use for your game and the one we want to news is just grow down to Kenny and just click on download. This is a set of graphics that we can use for this platformer game, And as you can see this, Scott is a little character there because some graphics for the environment as well so dello the this package and, uh, woke and started 2. 13 Import art and create animations: Now we have the Kenny Port package downloaded. Make sure you sounds a bit and you know you can find the platformer Pack folder and then that's good. Teoh the player for your and find this fire here p one sprite sheet. So does this going to be the spreadsheet use for character? I tracked that into your project. And remember, we want to make sure that this is a multiple spring. Let me just quickly open up the file so you can see that. But it looks like before we start slicing it here. So this is what that file looks like. And what we want to do is we want to start slicing each sort of character image into its own Sprite silicon enemy. And we've done this before. It's searches, go to multiple and click on the Sprite edited, and it's we're putting up despite had its there and click on slides, I think automatic work fine here, click on sly eyes and before we do that, actually, I want to change the pivot to bottom. So when a sort of the pivot point of the character be at the bottom off the sprites a slice , you can see that now I have all these individuals Sprite that I can use and generally names some of them. Right, So this is gonna be Look, and this is gonna be my jump Sprite, this this hurt sprite. And this is front. Finally, this is Look, I don't think that that's pretty good supply. That's fresh, the changes to spread it, to close it. And now you can see that we got no these different surprised that we could use. So I want to start creating animations for this character. So that's select all the ones that we didn't rename. So these are gonna be my walk animation kind of just could show you. So these these ones and that one arm I walk animation So I'm going to use there is just like that one and distract us into the scene and unity is gonna propped us to enter a name for this information. Just call this walk, okay? And notice that the characters is rather small. So that's changed the pixels. Two units setting to 50 make it twice as big. I think that's good. For now, um has changed this two player. It's got everything set up for us. And if we go to animation currency, that we have a walk animation that's automatically created when we drag all these sprys into the scene right in the nose where we have the animators set up for us a swell. So that's good. I can preview the animation, and that's gonna be a walk and a mention, and I just want to quickly set up Ah, a few more animations that we can use. So I want a Eido animation and there's nothing in it. So I'm just going to drag a front spray where the characters looking at the camera and then the stand Sprite, where characters looking forward and I'm going to copy this one. Copy the very first frame and pace it you create there so you can double click on the animation timeline to create create a knee, a key frame and copy paste that's bright onto the frame. So that's what I just did. So if we play this Idol intervention, that's what the character is gonna look like. One Theodore diminishes playing. I think it's a little bit fast, so I'm gonna change this change to samples to 30. Okay, it's good. We just double check the walk. Animation. I think the speed is fine. I don't need to change the simple. Yeah, sitting there. Okay. Okay. So that walk idol and I'm going to do a jump animation. And since we only have one frame, we only have one sprite image for the jump in emission. I'm just gonna go ahead and used that. So it's a single frame animation, and that's fine. No problems that Let's create another one called hurt. We're used us one. The player is hurt. Find enemy. And that's gonna be that one. So that's gonna be this? Yeah. Spread were used for the animation. And then finally okay, we're using Doc Animation. I'm not sure it will get to you, Um, actually using it, but its new home creating it. Drink this in again. That's gonna be a single frame intervention. So I got all my five animations created. If we go to the animator, see that they and mentions they're all in here ready to be used. Take it now. The next step, we're gonna create some before we go. That's important. Other graphic into the scene. Now I want to go to tiles. There are a lot of different tiles that we can use in this package and why I wanted something that we could use for that floor. I think this crash in management work now, just quickly. If you go to tiles spreadsheet, it's got all the different tiles on a spreadsheet that you can use to slice. Like what we just did earlier. And then you can use any of these in your game. We're not gonna use most of them. So I'm just gonna go to Tiles and let's just grab one for now. Let's just use the grass file in for that into the sea. Okay, so we have that. And again, if we just sort of track that and considers this is the tile, it looks it doesn't look at the smallest. I'm going to change that to change, to pick those two units, setting on this particular image to 50 as well. So that sort of matches up a little bit better. Boys. Our player Carrie 3. 14 Floor Tiling, 2D collider and rigidbody: Now I want to set up just seeing a little bit before we start creating interactions in it. So that's just duplicate this grass tile. 10. Just head control de or commend de, depending on your platform, and that's going to duplicate this subject. You can move it around now to make it line up perfectly. You can use the snapping tool. Ah, snapping function rather immunity where if you press down, if you hold on V and just click on one edge of the Thailand, then move it. As you can see, it automatically snaps and connects properly into the other tile, right? So again it's hold down V and then it's gonna try to find the right point for it to snap to . So that's very handy. And it's just keep sort of multiplying these tiles. Then the would envy snap it Gonna slick? No, he's may. Okay, Sorry. God, quite a few of these now gonna reset position for first. I can, actually. Now, that's not a good idea. Um, so Okay. Anyway, so that's these are mine. I think that's that's gonna be my floor. I want to do now select a mall sort of position and to the right position, and I want to put them all into one object. I want a group, then into one parent object. So I'm gonna call this parent object floor and I don't know the notice What I just did. Press down command ship and on the mag, or you can go to object, create empty now create an empty object. Remain this for, and I'm going to reset position 2000 with grass tiles into the subject. Most of going teachers changed the Y position on the's tiles, so they match the floor y position just so that I'm censoring things correctly you. And now I want to Attica lighter to all the tiles. And instead of having individual colliders, I'm just going to add it to this floor object, which contains all the tiles. So we're going to add component physics to day and box collider. And as you can see, the box collider doesn't quite fit properly with tiles because there's object. There's no mash data. It doesn't know the shape off the other objects doesn't know the shape of tiles, so we kind of have to manually change the box collider, which is fine. It's not a problem. If we just hold down shift. I can see that off a suddenly have these points that we can drag and control the collider on the subject. That's just mais he's colliders. Accidentally moving. Object. Okay, now the collided fits the tires. Okay, Great. Now the player object also needs collider and a rigid body. All right, so we get you're just gonna add a boss collider. You can see that the box collided, sits the character. Well, because it's Scott, despite rendering parliament so it knows how big the box should pay. And then we want to had a rigid body to de make sure that these are two D colliders and two d Richard body. Because we're working in two D environment and we want to use to write physics engine for it, right? So rigid body to day. And when fixed angles. So that actually that that's try without, and then I'll show you what happens. Okay, so that's just play the game. Notice that the something is a little bit funky here, looks like grab her gravity's and working properly. And the reason for that is because actually has nothing to do with gravity. It's because we have the applied read motion checked here. And when you have the apply room notion option checked in the animator, it's going to try to position your character based on the animation. So usually one this unchecked for two D animations, just so that we can position we can control the characters using scripts or playmaker or some other tools that we want to have better control over the motion of the character instead of having it be determined by the animation. So I'll check that, and then let's try that again. Right now we see that the physics works, right? Gravity works, okay. 4. 15 Player Control Left and Right: Now that's create some control for the player. We're gonna have a little bit of control going left and right and jump before we worry about hooking up the animations to the character. The first thing I'd do is go to assets in per package custom package and import the playmaker Unity to D package. Now, this is for those of you who have the commercial version of Playmaker don't Opry another set of videos to go over this point. So you click on open and you on import everything there are forwarded imported this into my project, so it's not going to show up, But basically, that allows you to have some two D actions in playmaker that you can use. Okay, let's get started with that click on floor. I'm gonna move this down a bit. So my room to come player, and then it's add state machine called this beneath, and I'm gonna call it a state machine. Okay, let's click on the action browser. The first step I would do is I want to be able to press left and right on the keyboard and have to carry to go left, right, So basically, I'm gonna map me our results or access to the velocity of the character. Alan, just show you how to do that. Click on the action browser guards get and the access name is going to be horrors. I don't know. And if you don't remember, and the input settings go to edit project settings and this is where all the input in unity can be managed. So the horizontal axis is determined by the left. What key or A and d t? And when? When the player press on these keys is gonna give you value on this excess that you can use to do various things in the game. So basically, we want to get that data from the horizontal access. I'm gonna put it in our variable. It's called those Just call those prices already. So I'm gonna put it in this float variable, and I want to get every frame next. I want to move this character based on this value. And after you import the playmaker Unity two year package, find the physics Trudy category here, click on it, and we want to set velocity to D. And we're just simply gonna map this value to the X axis, and we're also going to do it every frame. Let's have a quick test and then you see what I mean by having us control. So I'm gonna just select players and see what's going on here so you can see that are moving a character based on the input lefty and Rocky or a D. Obviously, it's a little bit slow. So what we could do is we can multiply, is by, say, five, and now it's going a lot faster. Okay, so I think five is a good number. Let's do that. Remember, at any change that you make when it's in play mode, communities in play mode is not going to be saved. So come back said that five safe. 5. 16 Jump: three things I want to do next, as related to the controls again. Now I have to move state, which is great for moving character left and right. But I want I want to also create a new state called Junk. This is when remove to carry it up. When the player presses up, we want the characters to jump So quick. Fiasco events North Korea. A jump event. Add that to the state and we're just going to do a simple Okay, keep down your rent. Sorry. Get T down action. And when the player presses, send them to jump state and in a jump state, we are going to dio something really simple, which is gonna set. They're lost t on the Y axis to a positive number. And then after that, well, he's back to the move state. Let's see what this This because we're in the me state. When I pressed up, character goes a little bit, so that looks great. Now the only problem is I can keep pressing up and it was just keep jumping and that's no, the result I want. Obviously we concluded some pretty cool. So the double jump type of mechanism. But I think for now I'm just gonna have where the player can only jump once. So for that to happen, we are gonna need to check and see if this character is on ground. So that's let's set that up now. 6. 17 Ground Check: to check and see if the player is on the ground. We're gonna use the line cast action. So let's go back to physics to D and fine line cast, right? So what this essentially does is casted line from the game. Object to a point. And if there are objects in between these two points, if this artificial line has an object we can decide what to do with it will construe or the object that's head into variable. Or we can simply store if there's anything that's head into a bull, veritable so I've just added the line cast action into the state, and now we would need a point for this line to go. We need a point to check and see if anything is in between these two points. So I'm going to create any MT game object and call this ground check, and I'm gonna simply create drag this into the player so that it's part of it's ah, it's a child. Object off the player and add a Nikon, since it doesn't have any mashed date on it, so that this is simply so that we're conceding the editor and I want to just reposition this and move it down just a little bit so that it's slightly below the box collider. So what this does now is the the like. Cast action is going to create a line from this game, object to this point. And if there's anything that heads this line, we are going to be able to use that information here. Okay, so let's go to Variables, and I'm just going to create a simple, poor variable called Is Grounded. It's gonna be false to start with against characters in mid air who will start game and let's go back to the state, Go to the line, cast action again. And first, that's drag ground. Check to the two game object field here, so we're casting from the game up, dragged to the ground check object, and we're going to store. The result off the check to is grounded, so when the line hits, anything is going to say, Oh, it's grounded. Now let's just have a quick test. It's one more thing we need to do, which is we want to make sure that we're only checking against the floor. All right, so let's go to the floor object click on layer, and I already added the floor layer so I can select here. But if you haven't click on layer at layer and then just at a new floor layer there, let's make the here on the floor length there. I could just change this object only. It's fine because this is the only object with attorneys lighter, and that's come back to the state. And if you scroll down to later mask and this, change that to one and change the element floor. So this means we're only checking against objects in the floor layer. Okay, now, if you play to see that now the ground is grounded. Very boys said too true, because now the players said, standing on the ground removed this player. You can see that when is in the air that's very bored, said to false. So it's constantly checking from the line cast Great. So the next step is easy. Now we have variable that tells us if the players on the ground just yeah, so have we add a Brill Test action to the jump? I stayed and we say was as grounded. If it's true, then continue to the next step. If it's not grounded, finished and we will not set philosophy to the player. That's a play. Now we could jump. We're gonna jump ones because one the characters in there, we're not allowing it to do. We're not allowing the said velocity treaty to be run again. 7. 18 Player Facing Direction: now you noticed that when I am pressing left right, the character faces the same direction. It doesn't change depending on the direction it's going. So I want to fix that. That's that's see how we can change that. The first thing, the one now, as you see you to cut the player character and just pay attention to scale as X or the X scale when it's a bigger number. Obviously the changing the scale of wise, the axe scale off the object. But if we set it to a negative number over Sudden is facing the other way. That's a quick wife was to change the direction of the image. So let's take advantage of that now. First, let's create a couple of simple states. Look right and that, and we're simply going to set scale the ex scale to negative warn. Wanted to look left and you can set ex girls to one. Wanted to look right. No. One. We're done setting the scale when I go back to the move state and from the move state one there. Great couple more events left, right and want to use the same action. Get key down to determine which state it needs to go to. So that's add those transitions first. That's right. Okay. And I'm gonna copy in Duplicate that three times. Get key down. Let's go left arrow key left and right there. Okey. The right on. One thing I do want to mention is you want to make sure that you use get key down instead of get key because we only wanna call this method once. One player press is the key. And we don't want to continue going back and forth between these two states. We only needed to go once running. You just said the scale ones. But anyway, so that's how we can quickly changed the direction off this character buys, which in the X scale. Just give this a quick test. See that to pay attention to the scale here can see that it's changing depending on the state. I mean, with t impressing 8. 19 Animator Conditions and Transitions: Now we have this character that we can control. That's kind of cool. But you notice that three character is stuck inthe e walking animation and it doesn't matter what we're doing. It just sort of has the same animation, and that's we have to do next. That's what we have to do next. Which is we want to start hooking up the animations into the different states of the character. And, as you can see that that were just in this walk animation state in The Animator. And this is actually the default state, which is why the character is sort of stuck in this state. So let me talk a little bit more about the animator again. So the animator is where we control or the animations and very similar to playmaker, where we have different stays for different actions. In the Animator, we have different animation states that controls different animations and also similar to playmaker we have implemented. We have these different transitions that helps us decide where to go which state to go to. Next in the animator have the same thing. Was transitions where we can say OK from the idols Date can go to walk state now. I just made a transition issue. Can see here that we do that again. Right click on the state. Actually, that's that's set Eido as the default state. First, I think that makes a little bit more sense. Idol Default state and make transition. Sure, we can go from the idols animation state to the Walk Animation State and then from the Walk and Emission State, I'm going to make a transition and then go back to the ideal state again. It's right Click make transition and then go to Mix State. I think I just created difficult. So moved that right. So what that does is creating this transition so you can go from the Idol animation to the walk animation and thats click on the audio animation again and you can see that transitions base layer idol to basically walk. Now you can have multiple layers to control your animation. We're not gonna worry about that for now, especially in two D. I think that's we don't really need to use it for now. If you click on transitions, it's gonna give you first of all, if you have this thing blocking the view you can change, You can just remove the preview. So you see the conditions here now the conditions as was determining when this transition happens, right? So the condition decides one. We should go from the Idol Animation State to Walk and the Nation State again. Click on the transition and it gives you these conditions that decides when this should happen. One. We should go from Idaho to walk, and right now it's said to exit time one, which means after one second we're gonna go from Idaho. Toe walk on. Let me just show you what happens or we leave that there can see the after one second. It goes from the Idol stage Walk State. And if you click on the walk State click on the transition and this transition goes from the walk. State backed Idaho State can see the Trent. The condition is the same. After one second, we can access this state and go to the next one so you can see that in the game view. We're going from one second of Eido animation to one second of the walk animation, right, so So that's kind of useful, but it's also no that interesting look in time. So if I change that to five and then it just get rid of this transition for now. So we just go from Idaho to walk to play. Okay, so we're gonna be in the Eido animation for five seconds, and then it's gonna go to walk animation, and it's just going to stay there because there's no transition in. There's no transition out of this state. Okay, so So that's fairly similar to what we do at the vigil state machine here and the benefit of having these transitions in these conditions as that, instead of having to tell the animates that what animations to play, who can actually define different conditions and let the enemy let the enemy dio decide which animation it should play. So remember if your videos ago we talked about how in playmaker you can call intimations, you can just tell the system. Okay, played the jump, intimation played hurt animation and you can still do that. But what we want to do now is to set up an intelligence system here, using again the transitions conditions and the parameters here that we can set up to have the animator intelligently know which animation to play 9. 20 Idle to Walk Animation Based on Speed: and I just realized I made a mistake in the previous video where I said, exact exit timers. Seconds is not in seconds. It in a cycle of it's basically how many times the animation should play, as you can see here. So this is a preview for you that if I put five here, then it's going to play the item animation five times before it goes to the next animation . So it's not. It's not seconds but normal, a normalized time for the duration of the animation. So if I put this 0.5 is gonna play half of that and the Idol animation and then goes to the walk animation. Obviously I consider Trickett that way as well. But anyways, so that's, um, the exit time condition. Now what we'd like to do is start using different conditions that are a little bit more intelligent. And as you can see that right now, you only have this exit time condition. But once we start adding parameters into the system, and currently there are four different types of parameters you can add to the animator, these are going to show up in the conditions Pano, and you can use that to do some logic to decide when you're gonna transition into which state. So, uh, for example, we're gonna do a quick example of this going from the Idaho State to the Walk State. And we want to check the speed the player is moving and used that decide if which a transition, a float perimeter. And that's gonna be It's called that speed and click on Eido. Click on this tradition, and instead of exit time, let's go speed And when the speed is greater than 0.1, then transition to the walk animation and similarly, that's right. Click on the walk animation, make transition, go back to idle and click on the transition. What we want to do is said the condition to check the variable speed. And when it's less when it's less than one, we are going to go back to the Idol animation. All right, so these are set up and they should be fairly intelligent, right? So all it needs to now, as the value of all we need to do is setting the value of the speed, and the animator is gonna decide which animation to play for us kind now, The problem is, the speed parameter has not been said yet. We don't have that logic in the game. So let's go back to Playmaker and click on the player to go back to our move state. We're gonna close these down now from set Lusty would know that we're setting were pushing the character left and right. So all we need to do is go to Action Browser. I don't want to get speed, get speak to D. It's pretty down there. So So when near the speed of the character, regardless of the direction regards is off the direction that the characters moving will get speed. And that's defined a variable called Speed again and that story to cut the speed of the character to the speed variable. And then we want to set the animator parameter to use this value here Service to set animated flute against flowed because this parameter here is afloat very well. So set animated flipped parameter its speed, which is the name off the perimeter here and valley we're gonna use this failure here, which is speed of the object. It's a little bit confusing, but may well change the variable name to something else to do. Okay, So again, get speed to D will get the speed of this player object putting player speed. Who would do this? A frame. And then we want to set the parameter of this animator controller here to the player speed that we just found again. We wanted to do this every frame. Okay, now, when we play this, pay attention to this perimeter here is as connected. Something is determining something is setting this speed here. And when we moved the character, you can see that down here, the perimeter is changing right there. The speed parameter is changing, and also the character is when it's not moving is in idle stayed. But its speed is bigger than 0.1 goes into a walk animation automatically. So that's that's pretty cool. And so we don't have to actually called his animation. You can just set the parameter and let the program determines that. So that's how you can set animations using these traditions and float parameter to decide to sort of control the animation state 10. 21 Jump Animation: great now for the jump animation. We're going to use different condition. We are going to use the trigger for them of you because what the trigger perimeter does is whenever it's triggered. It turns itself off in the next frame, so you don't have to turn it on enough, continuous. And it's great for something like if you're firing a weapon or if you're throwing a punch or something, like a jumping sort of animation where dickered that doesn't once and then stops doing it, it's a pretty good perimeter to use for those type of for setting up those type of conditions. And another thing I want to show you here. Is this any state box here like this block? And it basically represents like it's like the name any state. So if I create a transition from any state to jump, that means any state can go to jump regardless of if they have a transition to jump. So, for example, if I mean the Idol state and I triggered this jump, so I did it, and I have a condition that links those two. I would just do that quickly, so let me just into the condition is jumped. Oh, there's no other options here as soon as the jump trigger as triggered than we'll go to the jump state now notice. I don't have a transition from Idaho to jump or from walk to jump, but regardless of which state I'm in, as long as this condition is mad, we're gonna go from any state to jump state. So the any state is sort of a placeholder for anything that is going on any state that you might be in. So this allows is to go into the jump state from any state. So it doesn't really matter if we're in the item state of walk state or any other state. As Souness, the jump trigger is triggered. Then we're gonna go to jump State, okay? And from the jump stay, I want to make a transition back to the Idaho State. So when you finish the jumping animation, we're gonna go back to idle. Okay, so that's that's the hour. We can use the trigger parameter for this. Let's go back to play maker and it's finer Jump state here and all we want to do is again go to the Animator photo and we want to set animator trigger kidney. Yeah, So we want to make sure that this is below the first protest action records. When? If this has failed, then we're not going to jump. But one with ones were jumping when the trigger that jump animation. So that's the trigger Name is jump, which is the name here. Okay, so that's try that look at the enemy so you can see that we have this. It does go to the jump State very quickly. Leaves the jump state and back to the Idaho State. I wouldn't necessarily one that, all right? And the reason being the condition is exit time, which is one this means 100% off this one frame information. So basically, place the jump animation for one frame and stop. No, it's fixed that remember, we have this variable in the state machine called Is Grounded, which basically tells us when the character is back on the ground and we can probably use that full the animator as well. So let's go to the animator. Let's create a bull parameter and I'm gonna call. This is founded and from the jump state. Let's go to the transition. What is that? You can either click on the tradition here would click on the line directly, and we want the condition to be Have is grounded is true. Then we go back to idle. And if it's not grounded, meaning the character is still in the air, then we're going to keep the jumper animation, which again? Let me just show you what the Trump intervention looks like. Looks like that it's a one frame animation, so the character basically just has this post when when it's jumping, Okay, now the next thing we want to do again is to connect the variable to the parameter in the Animator. So let's go set in the Matrix if I can find it hit and we want to do it after the line cast . Because the line causes where we find who defined the value of off the dipole available, it's grounded. Okay, so the perimeter is is blanket again. That's the name off the parameter here, and value we're going to use is grounded again. We want we want to do it every frame. Okay, so let's give that a try. Okay, so we're in idle state walking junk notice how we're in the jump. Stayed on till we hit the ground. So that condition is working. Great. So now we've learned to use afloat variable afford parameter to determine speed and using that to decide which state we should be Which animations there we should be using. And also we use a trigger to start jump animation and use a bull parameter to decide where we should go back. Toothy Eido animation. Very cool. 11. 22 Fixed Angle: now remember, we mentioned the fixed angle option here in the Richard body to any component. And what this basically does is it stops your sprite, your true character here, some rotating. So with that, I'm tagged. Let's play this and then you'll see what I mean or go to the edge of this platform, can see that it's starting to rotate, and that's not something that we necessarily want. So what I'm gonna do is simply check that so that had stops the object from rotating. 12. 23 Add Force, Set Velocity, Physics Materials: Okay. The next thing I want to deter there is I want to create a wall, maybe on the left side of the screen, somewhere here and also something that the character can jump. So let's go back to her platformer pack for the tiles, and it's just fine the brick wall image contract that into our project. And again, I'm gonna set pixels two units to 50 just so that it's consistent with are the other ones. And that's tracked that into the scene. See that? Now we have this wall here and again, I'm gonna press them V and snap that object into position. So it's lying that perfectly with the tire blew. Okay. And I'm gonna add component. I want a collider on this thing as well, so that the character can interact with it. So I'm gonna pick the box collider. We're not even noticed. But there's a green line outline on the subject now, so that's that's all. Collider. If I turned that off, that's gonna disappear. Okay, Cool. So let's give that a try, okay? My character could dio and jump and you notice that there is a slight problem here. If I am in emit error, and I'm sort of pressed against this wall and I hold down the left arrow key notice that the character is sort of just stuck on the wall. So what's causing that? That's that's a problem when effects Well, let's go back to the player State Machine. Notice that we are here was setting the velocity directly, right? So we're saying, Well, let's get value from the horizontal axes and apply that directly onto the object. We're setting the velocity directly, and this is not always the way you want to move your character. There are a couple different things you can do. One is like what we're doing here. We're setting the velocity directly. So when you said the last three directly, it's going to ignore all of the other forces that's currently on the subject, right? And another thing you can do as you can go to the Action browser and Physics studio and use AdForce, which adds a new force onto the object while everything else on the object is still working . So the object has his own velocity, and then you add another force to it, and the system is going to calculate what that force does to the player character, a previous videos that we've done with actual years at force before. So if he wants refresh around those, I'll add a link to them again on the page. For now, I want to stick What said philosophy because 11 thing I like about sitting philosophy directly is you tend to have more control over how the character will be. Hey, and I think in this case, a to d platformer game. We don't necessarily want a lot of sort of natural feeling physics. So So we will probably end up using a combination of both adding forces and setting philosophies directly. Okay, So if I want to continue using sent velocity, how do I remove this problem where the character will get stuck to a wall and what's actually happening is when the character is right next to the wall and worth left? Herro key pressed down. It's going to have its going to try to several ah City to go that way continuously, and because this object has its own friction, it's stopping the character from moving downwards because this would where continuously applying this new velocity to its trying to go into this thing while the friction on this object is stopping it from sliding down. So there is actually very simple fix that we can do. I had to go to our object. The sorry, the project. Me. I'm going to reposition this guy here who can create and what we want as a physics to D material and that's named this material wall for now. All right, so I'm gonna put it in the right photo. And what physics material does has that allows you to define the friction and the bounciness off an object. And if we go back to this brick wall, can see that in the box collider. There is a material field where you can put a physics material in there. So what? That's drag the wall material that the one we just created into this field. So now this brick wall is gonna have the wall material if you click on it, which means it's gonna have a friction of 0.4 and zero bounciness are so friction determines how How, how something sort of stops movement. Right, Sir, if you have a an object was a lot of friction, then when the another object, it's running on top of it or alongside the speed or the velocity will slow down right there . It's going to slow down the object gradually and balancing those determines how bouncy this material will be when something heads it right. So it's easier if I just show you what they do. Uh, right. So well, let's just make that zero so we don't have any friction on it. And if we just play this now, we don't have that problem anymore. Even though we're setting velocity to this direction because there's no friction on the wall, it doesnt Character does not get stuck. Now. Another thing I want to do quickly is gonna improve. I'm gonna increase the amount of the jump to from 5 to 7 seas. As you can see, I'm still setting the last directly here, and I think it's fine was when you said velocity. One thing that's quite immediate is that every interaction is gonna be I've been, well, a bit snap here, right? So when you when you add force to an object, it because all the other forces are acting on the object they effect, it's not est immediate bring any case. That's, um so I've increased jump amount to seven because I want to jump on top of this thing. And also I want to change the balancing us too. 2.7, right? So it's between zero in Wana said it 2.7. Can we just play this thing? Okay, first, I think that's are enough. You can see that now. There's a bit of bounciness that's happening. One when the character lands on this wall. One thing I forgot to do it for a tip. Set this to the floor layer. Remember our ground check trucks for objects in the floor layer. So if I don't said this to the floor layer than I can't jump when the characters on top of this, let's try that again. Great. So that works. And also I don't have that problem of getting stuck on the side of the wall. So that's kid 13. 24 Polygon and Edge Colliders: So we've set up the environment with ease square looking tiles and I want something a little bit different now. This time I want something that's not a square looking one. So I can show you things that you can use different types of colliders you can use other than did the box collider that we've been using. So let's go back to our what and good items and fine rock the rock image spring that into our project. Okay, chance that. So this is not your looks. It's not quite a square looking object. So that's great spring that into a scene on if we go to the free TV on go to the war frame , you can see that this is toe shape of the mash right? And, uh, let's go back to two D view. So if I simply click on add component physics to D and Select Polygon Collider, extend that, you can see that the collider is basically the shape off the match. As the collider is basically, assistant will try to match the collider to the shape of the mash, and, uh, you can find out more about the collider here. One thing you can do is by holding down shift. I would be able to changed the shape off this polygon collided. Say, for example, you want us to match a little bit better. You should click on amid a part of a line that you can add another point, and you can also remove points. If he hold down, shift and commend. Click on the point. You can remove it Now. If you're on Windows, it's going to be shift and commend. Um, I mean shifting control to remove a point on this collider, right? So that's the Polygon Collider. It's removed that for now, nothing you can do is go choo. It's reposition this thing first, but say if the rockets down here right so we don't really care, have if there's acquited, I didn't know a certain point, All right, I say, If it's just like this, then we just want kind of a Kaleida here or to do, especially in two day. This is this is quite unique, as you can add competitive physics to D and can add an edge Cool idea, which is essentially a line, and then when you add a Naj collided, you have to manually change the shape of it. Otherwise, it's just gonna be a straight line here. We've created this edge collider that's off the shape of Thea purport of this rock. So if we press play consort of see how this work see that character is going up, there's edge here. Say is it's not quite that box collider, you know, it's a collider is basically shaped it we've defined. So that's the edge collider and it's it's pretty cool that soon let's use that I'm going to make that into the floor, Andi. But I also want to do is go back to the Rock and to your point on the bottom, notice that one night when I do that, it's sort of messed up the ach Collyer. So I'm gonna have to do that again. Actually, I'm Instead of using the collider, I'm just gonna use to Polygon collider just automatically generated for you. I kind of want this rock to go behind the floor, so checking which sporting layer these tires are, so it's in the default layer and the order is zero. So I'm just going to simply change that to negative one put that were there. Okay,