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

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

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

teacher avatar Brandon Wu, Founder of Studio Pepwuper - a Game Studio

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

12 Lessons (1h 24m)
    • 1. Introduction

    • 2. 31 Enemy

    • 3. 32 HP

    • 4. 33 HP GUI

    • 5. 34 Player Knockback

    • 6. 35 Fireball

    • 7. 36 Fireball AddForce

    • 8. 37 Fireball Instantiation

    • 9. 38 Fireball Add Torque

    • 10. 39 Fireball Collision Matrix

    • 11. 40 Fireball Enemy Hit

    • 12. 41 Wrap Up

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class


Note: This is part 4 in the series: Make a 2D Platformer Video Game with Unity and PlayMaker (no coding required). You can find part 1 here, part 2 here and part 3 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 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.

Meet Your Teacher

Teacher Profile Image

Brandon Wu

Founder of Studio Pepwuper - a Game Studio


Previously a strategist at Sony and a developer at Electronic Arts, Brandon is the founder of a game production company and co-founder of an augmented reality startup. He founded and grew a Seattle game developer community to 2000+ members and is a bestselling author on Brandon has been a mentor and a speaker for Cambridge University, Anglia Ruskin University, Microsoft, Cambridge University Press and many other organisations.

Student Endorsements:

Company: Studio Pepwuper: Twitter: See full profile

Class Ratings

Expectations Met?
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Introduction: welcome to part four of our two d game tutorial class for Unity and playmaker. If you haven't done the 1st 3 parts, you can find links in the description Were chorus over the section on. We've already looked at some animations to to grant face controls, physics and also camera. Now, in this part, we are going to add on enemy, uh, some HP before the player and we're gonna add a weapon to the game so that players come for that's a fire balls at the enemy. So we're going to try to finish this game in this part. If she feel like sharing after you've done the cores, please do so Paris on the four. I'd love to see what you've come up with, So without further ado, that's starting. 2. 31 Enemy: now that's create an enemy in the game to make it a little bit more challenging. Let's go to enemies. Your back. Um, I think the blocker mad. It's like a good image to use. Says tracked that into her, Seen or drank that inter project and just gonna make it a little bit bigger. Okay, now this regards in the scene, let's move it So sometimes. So this is kind of common. I'm trying to move this, but I can't, right. And if you notice that I can see the mash off this sprite, but I can't see the four control points and that's because I've collapsed the Sprite render . See if I open it the controls room? Sure, I and I can drag it around. I can rotate it again. So if you are having trouble finding some of the handles Madrid open the component, the components I'm gonna put It's got here. I mind Maeve the wreck object out of the way for now. Okay, Catch one. The enemies have a box collider and also a rigid body. I wanted to be a little bit heavier. Give it massive. 10. Okay, Now let's create some movements for this enemy character. It's part of our component Playmate State machine. So what I wanted to tell you is I wanted to jump left then right then left and then right. Just sort of keep jumping back forth. So I'm going to start was okay. State. We're gonna simply add force to this character. 50,000 3000 the wine. And that's run this and see what happens. So it should be adding a negative 1004 is on X, which goes to the left. And then why guns, too? The top. So I sort of had this little jump. That's good. I'm gonna create another state starting to jump. And I'm just gonna copy this on the only thing on change as on the axe taxes. I wanted to be positive numbers or it's going to the right and, uh, at a white action to the Trump left state. So I want to say after three seconds, it's gonna go to jump, right? And then it's at the finish transition and something here. Just copy the weight action here, have a finished state back, make sure that have finished the finish event. It's the finished transition just for testing changed that to one. I took up transition here. Okay, See? So I think you can say that. The object. It's jumping and it's rocking, too. The physics world, um, you can see that it's students weird thing in mid air, and that's because that we're not checking were not doing ground track before it goes to the next state. Sure, it's happening right now is before the object lands on the ground. It's to take long. It takes longer than one second for it to finish this transition. So Inari sculptures confront funny, letting movement, Which is kind of cool, actually, Um, I don't want it too much, but then we have a no toted and shooters moves around. 3. 32 HP: I could never have the enemy. We want the enemy to do something to the player, right? So whenever the player comes into contact with the enemy we want Teoh produced the health points on the player. Well, the first thing we need to do, obviously, is to create health points for the player. And it's gonna be very similar to how we created the coin variable in the data state machine. So let's start with that click on headed next to data. So you have access to the state machine. That's good of variables. Let's create another interoperable to call this H P. And I'm gonna set it to 100 that's gonna be the default value, okay? And then similarly, we want a event when the enemy hits the player. But because the enemy, if you click on it, open up. The collider is not a trigger, so I can't use true the result here, but we we want to do instead is a blinder collision collision to deviant and has created an event called Claire Pit so that when the enemy collides with the player can send this event . Just set that up first se. Um Okay, now. Similarly, let's make the enemy first. Name it on me. And then they had a tag. Gonna His enemy has the tag for this enemy Object player Data State Machine Gonna check for again, Click on that. And then it's gonna show your old attacks when check for enemies. So when the player collides, was the any object with Attack Enemy? It's gonna say players hit and we're gonna go to this event, this state. Let's see if that's properly hooked up a plane again. So when the enemy hits the player we went down to this state. Connecticut State is working. That's tell to state what we want to do when the player has hit by the enemy. So that's Teoh. Smooth to what we did. Corn, and you're into that can reduce the rich, be by 30 we're gonna reduce it by 30. So every time we hit the enemy, this number will go down by 13 and then run a track and see if this number it's below zero . Because witness zero that it's getting over and where you're gonna restore level. What? You're okay. We're gonna compare this number hp What's zero? And when it's equal or less then zero thing we're gonna send it to came over critics has created. I need them for So that's a look of this condition to the transition when HP zero equal was less than zero could it came over here otherwise. Gonna go back, Y no. Okay, Otherwise, we got to finish transition, go back to Idaho, then in the game over state, move a state. I want to just have a simple sort of effect where times those down on camera fade out to black for about two seconds and then we'll restore the local. Okay, so let's just do that quickly. Timescale time, scale. Time allows you to change the time, basically the internal clock off your game. So one is normal time. You can speed it up. So to be going twice as fast. Well, I'm going to do here. I'm gonna change it to 0.5. So when the character dies on the time slows down, okay? And then I'm going to your camera, fade out to pluck in three seconds. When that's done, it's going to finish event, and then we start level. Now, one thing we want to remember to do is reset to scale time back one. Otherwise, even after you restored the level, the time was day at half the Speed Racer, and then we don't want that. Then, Okay. Finally restarted level. Okay, so that's kind of the came over sequence for half Ruzyne for away from the the rest For now . Those air together. Okay. Credits runners and see if that's working properly. Okay, so we have our experience being decreased whenever the enemy hits us tens or one more time every day. Time has slowed down. Free, down. Restoring. Okay. So seems to be working quite well. Good, good. 4. 33 HP GUI: now similar to having this gooey text here. I'm gonna have a visual representation so that the player knows how much HP thes is the characters, their house. So I'm going to use a different approach. So instead of showing tax, I'm gonna have Hey, Bar represents the health. It's quite common health. Okay, so that's good to art pack. We just want a sort of generic looking image. Think speech, E p and J final work. So that your project. Okay, we're just gonna track that. And bananas P. It's just tentative fee positioning. I'm going to scale a swell. But instead of using the handles here from the Sprite directly, I'm going to use scaling tool because the problem with using these four points as his keeps toe ratio aspect ratio the image, uh, which is great, But that's not what I'm gonna do here. I'm gonna make it a little bit shorter like that. Keep skill. Ex Skerritt. One y 2 to 5. Can you do something like that too? Too much. Okay, let's do at one point trick the ex scale one, and I'll show you in a minute. Why? But, um yeah, that's do that and then I'm gonna go back to my Sprite. I like it better War a little bit small. OK, so I think that looks That looks all right. I'm gonna go with that. The reason why I wanted to keep this one is because when later on, we're going to calculate the percentage of the current health point. And I won't apply that directly to scale on this. Is this just sort of saved a bit of calculation there any days? Um, it's kind of nice to keep the pixels to unit consistent throughout the game. Anyway, since all the art has created together this were people did sizing ratios of things consistent from the original style. Okay, so we have that. Another thing I want to do is I want to reposition. The anchor point we're going to hear is as the Players page he gets smaller and smaller. We're gonna skill on the X passes, but we don't want it to sort of skill to the center. We wanted to sort of scale to the left. So we are going. Teoh, go back to this spread that we're using. And for pivot, we're going is just select left replying. That's repositioned this again. And as you can see that the pivot point has been changed to left skill, it's gonna give me that. It's gonna give us that effect. They want to see scaling to the left. Okay, it's on. The next thing we do is simply calculate the percentage of remaining remaining hp and then applying that percentage to the ex scale off this bar here. Okay, so let's do that first, define a variable called his P Gar. Sterile Christian. Okay, it's been long, but let's go with that name and we want to come clear that. And that's just simply going to be five hour flight. See flow operated reform work. Okay, Not great. Which basically allows you to do all these different operations on to float members. So we're gonna use okay, So run into a bit of a problem here. As you can see, that my HP originally is hey into trip Now I want to float from our percentage, see if I can find and operator that would allow me to do that. Try that The inter operator use RHP so that's gonna be my current HP. So it might be 70 When I hit parenting me and did your tour, I'm going to use 100 and we're simply going to do HP divided by 100 to get the ratio of page pain and store that now this is kind of annoying. E can't store that you and so scratch that. What I'm gonna have to do is, um, that's actually that's Instead of changing HP to throat, which we can certainly do, we can change. We can have converted hp into a float. Favorable. Uh, let me show you how to do that, actually is. Obviously we can change. We can go back, change the HP variable to float and then changed thes two actions to use float, ad and float pair, but that's use ties critically. Variable cough P that would near this saver boat, but it's have flowed instead of an int, and this was converted. Convert meant to float convert HP to be flipped. Okay, Now I can use float operated no organ. It's P float invited by 100 which is the original original point. If you change, there's then you want to make sure that changed that Divide this and then we're gonna say that store that in the scare percentage Terrible. And finally, we're going to sit. Let's go. Okay. And we want to set the rich people are objects x scale too. That percentage. So it's simply gonna be one times this number. And the one is This is why I wanted this To be one sort of have to deal with. If this is too, then I'll have to do to minus two multiplied by this percentage to get the new scale. But since this is why you can just simply use the percentage, right, so he's 100% and then it's this decreases will be percentage of that. Okay, So anyways, let's run this game and see if that worked. It's not quite working. That was positive. Second, see the HP. The scale is not being updated. So something is no changing here, right? So that's Ah, simple mistake. But basically, we don't want because I'm sending the state to different sending this standish into different states here. So none of this actually that says case already went to a different state. So I am going to amaze is to talking. So we don't run this until the end stronger them train. See that the health boy has increase. Maybe a bit too much. See, what's going on here is 11 just 10. So it's just sort of outside of our view here. That's why it's not showing up in Okay, so that's something we'll we'll have to fix its. Well, I want to make sure that health point stays invisible to player. Now. One thing we could definitely do is well, what happened was actually removed. A player camera moves. What those? And then it's because the health boys staying in the same position can. So the easy fixes just dragging the health hp bar into the man camera. So So it's sort of moves with the camera. Okay, good. So right, so that's pretty much working. I do want to add one was saying, which is I want to add a background to this hp far how much health is lost. All right, Um, and I'm just gonna reuse the same image. So that's duplicate th people number. Make this. His people are great. And so I want to now make crispy bar. His people are the child, his people background so that when this is we're scaling these, but don't scale background. Because if it's the other way around, then the back one gets scaled down as well. Now it's not obvious, but the meat change One thing that don't be very obvious to you next. So good color and changed the Alfa to 100. Now when we scale to be born, can see that the background stays at the same scale. Otherwise, if we have it the other way around, just show it to you. We scale this. The background has been scaled A swell because child object, Then we can actually see it. Okay, let's move that back and just double check and see if I have to write scaling the right object. Right? Okay. Trump Everything right? Yeah. Did a slight Sure. That's fine. Um, yeah, that's OK. Uh, one thing I did notice is we're setting scale before sending game over state. So sometimes he would have the negative scale goes, it's which is made. Basically, it's still visible there, but I'm not gonna worry too much about it. What we can do is we can act something here. It is said scale to zero. Then we won't have that little bit of its people are there? Actually, yeah. You got copy? Set scale. Yeah. So when it's game over, we want to just set this to their because we don't want many. Okay, so that's your work? Pretty wrong. Scared. Quick. Run. Great. 5. 34 Player Knockback: good. Now I want the player Teoh get knocked back when the enemy hits the player. Um, just so that the players would have loses control a little bit and it makes the damage. Seems a little bit more serious, right? So, Well, I'm going to try to do as Teoh in the data's state. I'm going to try to fine the force where the coalition happens, and I'm gonna use that to come plate which direction that players should be moving. And to do that, I need to use this action called Get Collision in front receiver. Find it. And for for us to use that we need to use the collision Enter two D event instead of sending a custom event from there's collision to the event action. So So that's good, cause that the the get collision to the info actually actually gives us a lot of information that we can use. So it's It's a good a good thing to learn about the coalition to the event. For now, I'm gonna add a transition Custom events, coercion and two D. Okay, so whenever a collision happens, it's gonna check. It's gonna go to the state. I'm going to create a new state called Trick Collision. Okay, so from here, Wandy Coalition, Trudy and fair action in this state in a store. The collider, the game object had the collider. So this was this Will tell me. Hit the player. Okay, next thing we want to know about this collision as the critical. What? I'm trying to figure out what is the direction if the player is head from the right side or the left side. So we want effective three. That tells us the looks like the collision store. That to the relative. We lost the variable set up before where we checked the attack of the collider. We're gonna do the same here. If the collider has tak enemy, then we still want to go to the player hit state. So first that's at the player. Had event back can remove this one. I'm gonna keep it for now, in case we want to go back to that to using the the old approach. But here, we're gonna have a player hit event. And when that happens, go to the player Head state. Otherwise, you go to the finish state and just go back to idle kind, ankle to action browser gonna compare tax game of Jack compared Tech and with a check the tag off the collider and if its enemy then could play ahead. If it's not, I could finish. Okay, so this Roy can still trek the attack on the collider. And if I just players quickly, you can start to see how this works. See, when I'm head excuse me, a lusty of the collision and also gives me the hit object Put it in the collider and everything I was still works the same way. So that's that's good. And now it's getting a bit more interesting. And by that I mean, it might get a little bit messy in our state machines. So I am going to try to organized things a little bit. Okay, so let's that let's think about this first, we now have the direction that the velocity of the coalition ist. And, um, I'm going Teoh, add a force to the player based on that, back to three. Okay, so let's do that. So from trick collision in for instead of player head going todo player, Head state, I'm gonna to a um no, the state here. Could you call this? Not back? So in this state, we are going Teoh moves to player backwards. So let's connect. Player. Do not back from once we had a to force. We're gonna go back. Two player hit state where we cut clicked hp can actually rename this to his que ese Okay. And then, um okay, let's let's do that first. And then there's nothing I want to do after this, but let's do that first. So go to our invective three category and first that's normalized. Normalize a velocity that we got because we want to be able to control exactly how much force were adding to the player. So by normalising the velocity we said gets read if the, um that the strength of the collision were sort of ignoring that right? So normalizing this is going to make this okay A with a length of one. So it basically makes it one unit. And, um, let's go use set back to three x y Z because what I want to do is I want to set wide 20 I've been ignore the UAE velocity off the collision, and my Israel, said Zia's Well, because even though Z is, we can pretty much ignore that because we're in two d space, since he is not being used. Basically, all I'm oh, I am interested in is really the X value. Okay, next, let's multiply factor three by stew 100. So So there's this is basically what we're gonna use. Teoh determined the strength off the knock back on the on the X axis. And finally, when you've it, this factor three so that it's going the opposite direction of To Hit otherwise, is when When your head, the player is going to try to go against the enemy and said, if bouncing away from it, I sure don't make one change. I'm gonna move the set back to three two after we invert because back to three and I'm gonna sit. Why, too, a number that I'm gonna use for the forced instead of zero. We're gonna sit that directly. Finally, that's ad for us to this player and even there, this is a two D action. The nice thing about this is there's erected three. They feed into this. Okay, so this way we will be adding a force whenever the player's head. Let's give it a try. You see that? The players, he means a little bit. It's It's a little bit funny and one of the things that we need to fix now it nor the boy I was playing around with it. One of the things we need to do now is this is one thing that we sort of touched upon earlier in the player control state we're setting for lost it directly. So what that means is, when we had fours to Deepak's exes because we're in the other statements from We're updating that directly. We're setting the values directly. It's going to override whatever force that's about being added on to his character, so that that kind of makes things messy. And also, one thing I do want to do is one the player's head. Want to let the player lose control for for a little bit? I think that that's kind of nice tude having the games Confront knows what it takes care of the problem of the control state taking over. Okay, velocity on the X axis, right? So that's what we are going to do now. And let me just tell you that the because I changed the variable hp variable to really large number because I don't want that player to keep dying when I'm testing this. And that's that's why the bar became massive when we were testing Just now. In any case, um, let's go to the action browser and that's fine. The enable Heffer same section. Let's put it top from the state and on check enable because we want to disable this and also find the control state machine and also on Chek Reset on accident. Otherwise, when we exit, this state is gonna re enable the state machine this which is not something we want. So we're gonna disabled control and we were really neighborhood. They talk. Okay, so if you just do that, I think I might have Yeah. Sorry. This is from a previous testing. Remove that. This is why you have currently so now does not back is working properly. Even though I don't my long no longer have control over the character. It's had forced action is making it behave. The behavior of it. It's quite good. Okay, good. So I disabled control here calculated to force I want ad had it down here. Now I want to make sure that the player regains control of two two seconds. War after the player has collided with another object, most likely would be the floor object. So yeah, so we'll give it two seconds. So that player loses control for two seconds and also won. The player hits floor again, and we're going to give the player the control back. Right? So we're going to create the new state here, and this would just be wait and want to do this after the h psb being calculated. So we want to calculate the impact on the players health. Wait. And they go back to my dough and Eido enable that statement seen. And this is what I had in the state for their so in a bow and then wanted so again on check recent on exit. And we want to enabled control State okay? And in the weight to restore control state first we have to wait rushing two seconds, then finish Also, Another thing we wanted to you is if the player hits floor. We also wanted to go back to the Ohio State. Now we don't have the floor tack, so I'm gonna give up now. Yeah, Thank floor. Make sure. Oh, my floor checks are tagged properly. Okay, All right. And make sure that idea collect wagon's floor. Now, that's players. So you can see that I have control, then I mean, there it's just started getting for self trolled doing there. But as soon as I hit the floor, I couldn't get true. It's dont worry. We tried to have a direction, so no, If I'm hit from the left inside the then hitting the player is not back to Right? Okay, so getting that sound, that's something that's working pretty well. 6. 35 Fireball: I don't think it's fair that the enemy can attack. The player with a player attacked the enemy. So that's create a mechanism where the player can shoot fireballs at the enemy. I think that would be pretty fun. So let's go to our pack again. That's fine. There should be an image that's suitable for area fireball. So this is what the image looks like. Okay, so we're gonna use that has a weapon. Okay? Again, drag bad into your project. And then I'm gonna put in a scene as well, just so that we can trick it a little bit. Okay. Ah, we want those to have a cold water. So that's do the Circle Collider again. Again. It's too big. And the reason for that it's because image is not properly trumped. Sorry. Concede that the image is actually much bigger. Then the fire service much bigger than the image there. We can go and tweak the image in photo shop or some other Softwares. Um, for now, we're not gonna worry about it too much. That's just gonna make this a bit bigger. And also it's just changed the radius to something like that. So it fits in the with the image E circle quieter. Add a little body toward this realm. Okay, collider and a rigid body. And I want Teoh. Make sure that we have gravity applied. So, um, we're gonna use the physics to determine how the fireball moves. What I want to create is something like what we see in Super Mario brothers, where the fireball comes out at an angle and it sort of bounces off the ground. And we're gonna use physics for that. So we're gonna have one this to have gravity and various different physics applied to it. Okay, so we have these two ready. Next thing we want to do is applying a physics material toe so we can control control that bounciness of it. And I wanted to be really bouncy. So, um, we've done this earlier with the wall. So now let's just go to create physics to D material. I'm gonna call this rounds four fire. Put this in mind for you here, keeping things organized, okay? And click on this physics material that we just created gonna remove friction. I'm gonna give it bounciness of one. So that's gonna make it really bouncy. and I'm gonna put this here So we're gonna put this physics material that would just create it to into the collider material. So when we were, just play this, pay attention to the fireball here, see how it's really, really bouncy. It's, um, it's not losing much. Amends him at all because balancing this was 11 being the highest number there. Okay, so that's getting that's that's kind of cool. Now, before we continue, I want to make sure that we make Fireball into a prefab. The easiest way to do that, it's just by dragging it into your project panel. Now, why do I want it to be a prefect? Because I want to be able to instead initiated. I want to be able to continuously create new ones when the player clicks on the fire button , right click on the shoot button. So So there we have pre sap and let's give you that great safe 7. 36 Fireball AddForce: Okay, so it's It's pretty cool that fireball would bounce around, but we always wanted to have an initial forced to move it forward. So what's gonna happen is we're gonna create a function where the player would click when the mouse button and we're gonna create. For instance, she ate this fallible, and we want to add a force for it to go sort of that way, right? So that movement we needs to we need to add it to this ball itself. So let's go ahead and do that. I'm going to make the changes on the prefab, make sure that we're making changes to the prefab instead of any instance of it. I just read that for now. Please up. Add component. Playmaker, Playwright. So I stayed in it. Realization, and we are simply going to find Another thing we need to consider is to put this back here . I want the ball is depending on the direction the players facing, we want bolt or the go to the right or left eso. If the current is facing the other way, we want to add force in that direction. So that's one thing we need. Teoh need to take care of. Okay, so go back. Teoh. Prefect, Just by way, if you click on an instance of a prefab playmaker doesn't allow you to add it. The instance. Usually it's usually not a good idea to do that. So click. I'm added prefab, and that will dramatically select pre fat for you to read it. Okay, so in this start, what we want to do is we want to find the direction the players face. Remember way used the X scale here to change the direction of the player. So that's what we're going to check. I just to show you here, look left were sitting there ex scale to negative one for it to go the other way to look the other way. Okay, so first we're gonna find a player object Foreign came object with the player attack because the player is tagged with the player attack, going to store it in the player variable. Then we're gonna get scale if their object and I need something to hold the X scale value. I'm gonna crediting flute where you and here getting the eggs scale too off the player, and I'm gonna put it in this variable. Okay, now let's put the AdForce action in their first. So we kind of know what's what. What's required. All right, So we have this ad floors and we're going to supply it with an Axe Valley. And why value now the X value. We're gonna create another variable for it. Teoh Force. It's quite a force. That's fine. And still 100 50. Now I can just use force. But the problem is I'm ignoring the direction that player is facing. So we need to do. It's fairly straightforward. We'll just do a float multiplying, right? So force is multiplied by players scale acts because we know that the scale of the players are there gonna be one were negative one in the simple crazy. Obviously, it's your game, Uh, has a mechanism where you scared the player up and down. Then we need to be careful with that. What I would do is probably once we get scale, we try to normalize it. Like what we did before what they are not back so that we get back to a unit of one in any case. So this is why are they gonna be one or negative one, which gives, says it positive force or negative force on the X. So I think that should touch your work. That's Ah, let's give that a try first before I had to play because I want to just look at the game frame by frame. Okay, then click on that. See that? Now the ball is moving to the right slightly. We're not adding a lot of force to it, but it didn't go straight downs moving slightly to the right. So that's good. So that means I worked. Why in the players facing to the right now, that's try the other way. Yeah, true directions. The player again, Let's play it by the frame. The same. You can see that the fire boys moving to left side Lee. So I'm not have to your increased the force a bit. Okay, so that's that's good. Since you working right? That's just changed the forced. Now, before I forget 200 8. 37 Fireball Instantiation: can. Now, let's go back to the player control. Make sure that you're in the control state machine and we're gonna add another event here that goes to a shoot state. So we're gonna have shoot state where the player was. Shoot the enemy. Okay. And, uh, let's see. Kind of took up the keys first, So we're gonna get key down treatments to get button down. Fire one now, Far one. What is fire One. Forget to edit project settings. Input here. Remember, we talked about the access here before the fire. One named fire One corresponds to the left control button. The left control key or mouse zero, which is the left mouse button. And you can sort of change things here, but I'm going to use fire one in my state. Let's go back to that state. Okay, so if it's if ah, fire, one button is pressed, then it's add an event. Shoot, Fireball, Shoot! Fireball, Go there. Right. We're gonna shoot fireball, have press on the fire. One button in the shoot. State. I understand shape or rather create, create object. Um, so in playmaker, it's called create Object in code is instant shape, but it's essentially the same thing. So here, game object. We're gonna drag our prefab in here. Okay, now Spawn Point. You can leave that empty. And what that's gonna do is it's going to, um, instead, she ate a fireable from the player, and that might look a little bit odd. Let's just let's take a look at that. That's first finish a state when it's done, go back to move right and get rid of this one. So that was a Chevy. How, whereas instead, shade. So it's sort of instance created from right. So without a spoon point, it's just sort of extension from the 000 point, but just not where we want. You can't drag player here, so it's gonna use the players position. But that might did say, I'm not sure if that's what we want. I there see, it's it's sort of shooting from the bottom of the player because that's where the banker pointers. Uh, that time looks funny as well, so we don't want that. Now we can do something similar to what we did was ground check where we create an empty game object that just holds the transform positions night transform vectors. So let's do that. And I can just go to game object, create empty and then called Is Fire coal going? And move that into the player insert in there. It's a child object off. The player sort of moves around with it with the player. I'm gonna give it a red icon so you can see it in the scene. Otherwise I can't see it. Right. Um and then I'm going to reset the position and then dragged somewhere here. I think I wanted to be used for this in front of the player. Another thing we have to think about is if you start from here my running into a problem where the fire boys colliding with the player right away and that's not that's gonna cost in problems, right? Because that's going to stop the fireball from moving. So we're gonna move this a little bit further to the front. If for some reason you really want us to spot from this position, Um, there is a way we can turn off collision between these two. I'll show you that in a bit, but that's just for now. Let's move this outside of the player. Okay, Right. That's it. Straight out. We are moving. Jumping. I have got Teoh change the position. Right? So it's still spawning from a player. Strike that in here. Okay, Each other again. My apologies for that stick. Okay, now it's going right place making. 9. 38 Fireball Add Torque: So now we have to find role. It's not. It's not quite there yet. Noticed. They sort of staying the scene. They just sort of pile up. They don't disappear. So the first thing I want to do is I want to give them a life. Spain Life Span says it may be have to 235 seconds. They disappear. And also I quite like them to rotate a bit right, because right now they just sort of they don't really look like how I imagined fireballs to to look in real life, obviously. So that's let's go to the fireball prefab in See what we can do now that's that's sort of fixed the rotation first. So instead of adding on top of adding force to day, let's go and had torque right and then we just give it. Sure, what's the number here? Okay, plants, Avis stars rotating. So it does start rotating. But I think the direction is wrong. Let's say, yeah, I think I want a negative number there, So go back. It's now. Do you negative 45 And I think the force, maybe I'll make that bigger number as well, my friend. So a lot of times you spend a lot of effort sort of figuring out what feels right. Like, how is this how you want your game to feel so obviously with 500 talk? It's a lot more interesting now with fire Five goals. I think 500 might be a bit much. 20 down bet. Okay. And then after there's we're gonna add a weight faction, wait three seconds and then finish, and it's gonna destroy itself. That's it. That's, um so this way we don't end up with a ton of fireballs and seeing it is cool, but same time, they, uh, kind of become an obstacle in the scene. Now, you see that my character is sort of jumping on top of them, Um, actually Curtis balancing on them because they've got that really bouncy physics material. So I want to change that. And remember what I was telling you about. No, I just know that guy off about collisions, how you can use different layers to avoid collisions between the fireball and the player. So let's do that 10. 39 Fireball Collision Matrix: so really cool thing in unity is Thea Bility two stops to ignore collusions between different layers. So I'm sure how to do that. We knew that a player is in the default layer and five all those in the default there. So that's not good. We need to make sure that they're in two different layers. So I'm gonna put player in the play earlier. If you don't have this layer, go to have their have bean player and then go back to the player object, go back to layer again and then selected. So I'm gonna sign player to the player there. All right, this doesn't really matter. Okay? Now I'm gutted five all, and I'm gonna sign it to the weapon later and again, if you don't have it added yourself, and then make sure that you're adding you're assigning layer to the prefab, okay? It project settings and then physics today. Now, here you can define some basic default values for the physics gravity default material, uh, various things, and then the thing we really want to take a look right now is the layer collision matrix. So here you can on check the interactions between two layers. So, for example, I don't want players to interact. What weapons? I don't want players to collide with weapons, so I find a player there, here, and then find a weapon there. Now, I have one Here. Have one here. So the intersection between these two, it's this box here. So I'm just gonna on check it. So this way that the player, everything in the player layer and things in the weapon layer, they are not going to collide. So that's that's getting out on one. Those two to quite second you can also. Secondly, you can also tell weapons to not coli with each other, right? So if you want fireable, it's sort of just go through each other. We can just do that. Then they won't sort of pile up. All right, so I'll check those two and see what happens. Crazy that the fireball is just going through character. And they also don't call I with, unlike before where they sort of pile up. Now they just go through each other. Okay, so So I think that's the behavior I want. Obviously, depending on your game, these are You can decided to have weapons sort of collide collide with themselves. That might be an interesting mechanism for for a sort of puzzle action game, but for now, I'm gonna sort of leave that unchecked. 11. 40 Fireball Enemy Hit: can. Now we have this cool for a bowl of fact brothers and in fact, weapon. Well, you want to make sure that actually does something to the enemy. I mean, right now is sort of moved enemy around a little bit. Um, it doesn't care which is no good for other hero here. So So that's let's go ahead and do that show. Okay, so that's good to the enemy. Uh, actually, I think I wanna make this a pre Fabrice. Well, cause we're gonna have more than just one. Let's make that into Prefect. There we go. And we wanted to basically die when its head by the fireball. So we're gonna add any state, and I'm just going to say destroyed for did, and I'm gonna add a global transition. Now, global transition allows you to go into this particular state regardless off which states you're currently in. Let me just add this first, so I'm going to do collision into two day so usually to go to, for example, in this case, to go to the jump right? Stay. You have to be in this state and then a valuable connect ones day to the other but was a global transition. As soon as this event happens, regardless of which state were turned the end, we're gonna go to this head of state. Right? Okay, So when a collision antis when a collision happens with the enemy, Look, we're gonna do something to it. We're gonna tag if the collider is a fireable. So we're gonna I'm using this one. So let's create any game object called Collider. And in the hit state has to question today, you said, and we're going to store it. He came object hit in the collider object Clyde available? None. It's check tag of that object so that to the collider to see if it's the fireball. Now, make sure we have to fireable tag. It's vulnerable. Okay, so you might not have that. So go to add tag. Make sure that this fireball prefab has attack findable. Oops. Okay, let's go back to your enemy. Look, And if it's true, we're going to say destroy event, We're gonna have that event here, Troy itself state. Okay, now, finally, we want to have one more action called. I Can't find it. I'm gonna search for it. Go to previous State Now, why do we need this? The thing is, if we start was because we don't know where what the previous state is, we can either always go back to jumping left what we can try to go to, Well, whatever the previous state is. So I think it's probably a good idea to have this here, Although it doesn't really matter that much. Since we don't we don't really care for a super precise movement positioning off the enemy . I think it's kind of fun when IDs a little bit random. So I'm gonna just tell it to go back to the previous state. Have the collider is not a fireball just basically ignoring what happened here and finally destroy itself. Uh, steer destroy. Okay. To run that and see how it behaves. Okay, so my parents died, basically, is jumping. Seems to be okay so far. Now, once I started shooting it, I didn't have any effect to success. I sort of past the recording for bed to investigate what's going on. And I think there might be a bug right now when I when I'm recording. This was the collision into two D, um, action. Along with the layers because everything is set up. Probably I'm not sure was working. But, um, that's not worry about that, because there are things we can do to continue. So instead of using a global transition event, that's just have it's set up. Sensed the way where you normally do anyway. So as dio a collision, you can't collision to the event and there's put the collider into and check and see if it's a fireable. And if it is, in a sense, it event, it's at the event. Uh, check my spelling right. Gonna do the hit event which would have that event here and still get through. They're every of that, too. And here the same thing I'm gonna add to hit event tread copy and paste his action in check for the same fireball collision that happens to hit. And here we don't need these two anymore because we already checked for the tag up here. This might be a clean away today. Just try select the subject. Okay, so it's good. It's going to it. Right? Um state. That's good. Have to fire. Going to see that. Okay, Now I want there is, um, have a little bit of sort of effect before we destroy. Because object just gonna change that to the finished state. Okay. Um, so wait two seconds for destroy the object. And using that two second period, I am going Teoh a few things to see. She used the point action. So this is kind of a fun little action. Um, Basically just turns the renderers on the object on enough. So you'll see this. I'm check blank. Basically, I want to. Okay, sure, but that looks like All right, so it starts pointing. If that number is smaller than it's gonna go faster, let's do that. And also less its head. I want to remove the collider on this because I don't want to steer interact with other things. So let's get out. See if you can control directly here. I don't think there's an action to turn that off, but that's okay. Just double track and see if there's anything in physics to D that we can use. Really Seer usar set property feature of playmaking. So simply drag. We do it again. Drag this component down here and a set property. So I want to do is I want to teach others into a trigger so it stays in the scene. But it doesn't continue to interact with anything else. Okay, let's see if I can find it is triggered property and just make that true. Tripped up okay to see how that looks. Okay, so it's just sort of comes transparent that starts blinking. And then it would have fourth food the floor because it's no longer a collider and it's just sort of disappeared. This is just sort of fall us off the screen, so that's fine. That's kind of a fun. I'm fun, though. It's perfect for half. 12. 41 Wrap Up: Okay, so we put in this half everything we need to start making this game, I would have just cuter enemy. We have some floor tiles that we can use to construct the level. So one thing you probably want to do is make the coined A prefab, basically anything that you want to duplicate in real time run, tired runtime or at editor time. Make sure you should have turned them into pre fabs. Just gonna do this now as floored. I'm gonna get rid of this one. Just keep that on the gang. We're gonna use the snap. Okay? Right. So we can start sort of creating more interesting level, rose just using what we have and duplicate coins. Start building level that you want a goat. Obviously, you can do this better than I d. I'm sure, Sarah, I'm gonna leave that to you to create a fun platformer game using some of the tools that we've introduced in this course and, um, should hopefully have fun with some of these new unity to d features. I definitely a little fun creating this course. All right, so one final thing you can't create a sort of massive collider is below the level. So when the player falls, then it's game over restoring. I'm not gonna go into that. You know how to do that. So? So again, that's thistles. Pretty much it. Have fun and share your project with the rest of the class. I look forward to seeing Oh, off your interesting and fun. I lost my game. I look forward to all your interesting and fun, uh, platform games the phone.