Unity - Designing and Coding A Platformer! Learn code and design through context! | Christopher "Gray Hato Games" | Skillshare

Playback Speed

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

Unity - Designing and Coding A Platformer! Learn code and design through context!

teacher avatar Christopher "Gray Hato Games", Learning in Context

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

23 Lessons (3h 35m)
    • 1. Intro

    • 2. Level0 Installing Unity

    • 3. Level1 Setting Up

    • 4. Level2 A Hero Is Born

    • 5. Level3 Player Movement

    • 6. Level4 Jumping

    • 7. Level5 Animation

    • 8. Level6 Variables

    • 9. Level7 Collision Detection

    • 10. Level8 Animation Frame Recording

    • 11. Level9 Music and SFX

    • 12. Level10 Coin Collecting

    • 13. Level11 Game Over

    • 14. Level12 You Win

    • 15. Level13 Title Screen

    • 16. Level14 Camera Movement

    • 17. Level15 Extra Levels

    • 18. Level16 UI

    • 19. Level17 Bouncy Box

    • 20. Level18 Death Animation

    • 21. Level19 Enemies

    • 22. Level20 Finishing Up

    • 23. A Special Thank You

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

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

Our final project:  https://grayhato.itch.io/skill-share-runny-jumps

In this class, we will make a fully functional platformer game focusing on programming and game design. The project includes running, jumping, item collecting, basic animation, and every part of Unity needed to make games and a jumping board to do bigger projects.

At the end you will have:

A title Screen, 2 Levels complete with collectable items, obstacles, and an enemy, a GameOver Screen, a Win Screen, and it will be functional with both a keyboard and a Bluetooth game controller.

Meet Your Teacher

Teacher Profile Image

Christopher "Gray Hato Games"

Learning in Context


Hello, I'm Chris and an indie developer and programmer for videogames.  Join me and learn basics and fundamentals of game design and programming.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
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.


21. Level19 Enemies: Okay, and welcome to bonus level part two. I'm going to go ahead and make the enemy with you. It's going to be a little bit more coding, but it may be easy enough to understand. So we're going to go to art. I'm gonna go to our enemy, be here. I'm gonna go, I'm going to change into 25 for pixels Brianna, spread or apply. We're gonna go to, we're going to go to from single to multiple, going to get a Sprite Editor apply. I'm going to go slice automatic. And I'm going to use this B here, these three in the middle. So click Apply. Let's go ahead and bring our B over here. And let's see here, I'm going to go to rename it to an enemy B. And I'm going to go to create assets, animations. We're going to call it Enemy, be flying. Save. And then I'm going to get these three B's. I like things starting at the left. So we're going to, these three. B is 1, 2, 3, with all them highlighted, I'm going to drag it into here. And if I press play, he's gone a little too fast. He's a turbo being slowed down a bit. I'm going to put them at maybe 20. Still wanted too much, about 16. So we stand multiple eight. There you go. That looks pretty good. Now with our b there, we're going to add a quick circle collider. And remember, with obstacles and enemies, you want to make it a little bit smaller. You don't want them to feel like they barely got touched by it. You don't want them to feel cheated. We're going to bring it in right there so you can touch his wings, you'll be okay. And with that, I'm going to hit Control S to save. Okay, with that we've got, we need to make a script for our B. So I'm going to go into our scripts. I'm going to right-click go to Create C-sharp script. I'm going to call this enemy script. And we're going to open it up here. And we've got a bit of typing here. So basically what we want to do is we want to create a situation where the bee flies to the right. When he realizes he's gotten far enough, he turns around and goes back. So we're going to need several variables. We need the public float x position, left. Public float x position, right. Public, int, go to position. And then we need public float speed. So this is going to be his leftmost position, his rightmost position, deciding where he needs to gum and then how fast he's going. So we need two things at the beginning, we're going to auto set something. So I'm going to say x position left equals this dot transform, dot position dot x. You don't have to put this end, but I like to say as soon as the game starts, it's going to automatically assign his position to where he currently is. So it's basically a starting position. And then we're going to go to position equals one. So now in our update frame or update method. So now in our update method, we need to set a condition for going left and a condition for going right. So set, go to position four left. And we're going to say if this dot transform, so if the B, we're going to put this on our B, if this dot transform dot position dot x is greater than or equal to x position, right? So if it's, if it goes past the exposition, right? If it goes farther than the exposition, right? We're going to say, go to position equals one. And then we need to set the opposite. So we're going to say set go to position for right. And we're gonna say if this stock Transform about position dot x is less than or equal to x, position left. Go to position equals 2. So let me explain this really quick. So we're saying greater than or equal to. It means exactly that, right? If it's bigger than or the same amount, less than or equal to means less than or the same amount. So if he's too far right, we're gonna do with a go-to position is going to be one. And if he's too far left, the go-to position is going to be two. So now we're going to set left movement. So for that we're going to say, if go to position equals, equals 1. So remember this equals, equals means, is it equal? It's asking if it's equal. So if the go-to position equals one, and remember it's going to be equal to 1 anytime the player goes too far to the right, we're going to say this dot transform dot position minus equals. This means subtract new vector 3 speed times Time.deltaTime, same as what we did with our player pretty much. So this is the x value. The y value is going to be 0 and the z value is going to be 0. So it's going to move him. It's going to subtract from his position. So it's going to move him left. And then we can just copy all of this. Paste it in here, rename this to offset right movement. And if it's when it's go to position two. So if it's went too far left, we want to move him back right? We're going to say this dot transformed opposition plus equals speed times Time.deltaTime. By the way, if you wanted to make this for up and down, the only thing you would have to do actually is to change this right here to put it over on the Y value and then bringing 0 to here. So you can literally just erase this and put it here. And you're now going up and down if you want to make horizontal bees as well. Okay? Now we need one more thing. Same as our player for facing IRBs facing left. We want him to be facing left, or if he's going. One more thing, the same with our player, B is going left. We want them to be facing left. So remember by default in the animation, he's facing bright. So if he's going left, we're going to say this dot get component, sprite, renderer dot flip x equals true when he's going left. And copy this code down here. Whenever he's facing right, we're gonna say it's false. So with that, I think we have all we need for our B. So I'm going to go in here. I'm going to put this on. Okay, I'm going to select our B, C prefab. Now. I'm going to select our B. I'm gonna go down, I'm going to add component. I'm gonna say enemy script. And now there's only two things we need to set here. We need to set our speed and I'll put it at five. That seems good. And we need it put, set our position right? And the way we're going to set our position right, find out where you want him to go. So this is wherever you move it, it's going to be the start position. He's going to start by moving right and then left. So starting here, the series axis as x is 23.5. I want him to go. Maybe 32. 32 is as far right as I want them to go. So moving back to, I want him to go. And they said 32. So I'm going to get 32 here. So you only need to set the exposition right, and the speed. And one more thing, let's give him a deaf marker. We're going to hit play. Let's see if it's working right. Look at him, go look at that beaker. If we touch him. Okay? And with that, it's going to make your game a little bit more fun. So I will see you in another one.