Subtitles section Play video Print subtitles [MUSIC PLAYING] COLTON OGDEN: All right. Welcome back to GD50. This is Lecture 8. Today we're going to be diving into the world of Unity for the first time, which I'm excited about. Going to be a whirlwind tour, but I'll try to cover as much as possible. Transitioning away from 2D and away from Lua and LOVE 2D into 3D and C# in the context of Unity. Today we'll be talking about Helicopter Game 3D. So Helicopter Game is a 2D game that was really famous in the 2000s. It was a web game. I was sponsored on a bunch of websites. Addictinggames.com still has it on there, and a few other websites have it. It was a flash game. But I remember playing it a lot. It was the old precursor to Flappy Bird, which was mentioned on the Wikipedia page. There's a reference to it there. And this is what the game play looked like. It was very similar to Flappy Bird-- a little bit different in that, instead of trying to avoid pipes, you're in a cave, and you're trying to avoid the ceiling and the ground of the level. And there were these little obstacles that would spawn in the middle, as well. So you'd have to navigate that. But it was the same exact mechanic-- the sort of like, click to go up. And then, when you didn't click, your helicopter would just sink down via gravity. Today we'll be talking about a bunch of brand new topics, things like Unity, first and foremost-- the ecosystem with which we'll be doing a lot of the things we'll be doing. C# is the primary language we'll be using. So we're going to take a step away from dynamic languages and move towards statically-typed languages-- languages like C#, and Java, and the like. Blender is a program we'll look at briefly today, just because, in the context of 3D development, you're going to want to have a tool that will let you create models. And so the 3D software that I like to advocate for the most, especially for folks that are just starting out, is Blender, because it's free, and open source, and it has much the same feature set as any commercial software, like 3D Studio Max, and Cinema 4D, and the like. We'll talk about what components are-- entities and components, how they relate in this model that Unity has adopted for all of its programming. Components are little pieces of behavior that you can then combine to form a whole, that will then drive the behavior of whatever object in your scene you want, rather than having to customize its behavior via a long chain of inheritance and instantiation. Colliders and triggers are important in 3D-- and 2D. But today we'll be talking about colliders and triggers-- things like the helicopter colliding with coins, and buildings, and other planes that are flying. Each of those has to have a collider. And certain things have to be considered triggers in order to trigger certain behavior with other entities. Prefabs and spawning-- prefabs is a huge concept in Unity. So prefabs are basically prefabricated objects that you can customize as you want to-- lay them out in the editor, rather than having to necessarily code all the details. And then you can instantiate them in the actual scene, via code programmatically, in a way that fits the model you're striving for. Texture scrolling is something we'll look at briefly, because it's the way that we accomplish the infinite scrolling aesthetic or behavior. And we'll look at how we can do that in a different way than we've done before, using u-v coordinates, and specifically looking at materials, and modifying certain attributes of those materials. And lastly, to tie everything together as we've done before, we'll look at audio-- things like audio listeners and audio sources-- what the difference is between them, and how to add them easily to our game project. But first, a demo-- if there would be anybody willing to come up and take a look and play the 3D helicopter game that I put together, that would be awesome. Anybody? Steven? Awesome. Thank you so much. Let me go ahead and actually get it-- so I've pre-built it. So let me go ahead and. So the nice thing about Unity is, it exports to multiple platforms. And right out of the gate, you can get just a-- I didn't put an icon for it. But you can create just a native application very easily. And so whenever you're ready, go ahead and hit Play, and Up and Down will move your helicopter. So this is the 3D helicopter game. And I don't think we have sound live, but there should be audio. Oh, I might have actually-- here we go. [MUSIC PLAYING] There we go. That was my bad. So there is music playing. There's sound effects. So notice that we have a 3D model. This is what's called a 2.5D game. So even though everything is in 3D-- the models and so forth-- the actual axes upon which we're bound are just two. We're just bound to, I believe, the x and the y. Could be the z and the x. I don't recall offhand. But we're bound to just simply two axes of movement. But all the models, as we can see by the camera, are in 3D, including our helicopter. So we have a few things going on. We have skyscrapers that are scrolling by. We have coins that are also going by at the same speed as the skyscrapers. We have a background that is infinitely scrolling. We have, of course, our helicopter which has a rotating set of blades. And when we collide with a coin, notice that we get a little-- it might be hard to see in house, but we have a little particle effect that plays. There's airplanes that are flying up top, so we're instantiating those, as well, to fly past us to provide another layer of obstacle. And if we collide with an airplane, notice that we get de-spawned, and then we trigger another particle effect to imitate an explosion. And then, notice we also have a couple of other elements. We have a GUI. We have two GUI elements-- a coin total at the top right, and then a game over here in the middle of the screen, which only shows up once we have died. And the explosive behavior-- if you want to collide with a building, you'll see that. It also triggers when you collide with a building. So there's two things looking for these explosions-- the airplanes up top, and the buildings below. Those are our two obstacles. But when they collide with the coins, we should increment our coin total, and then display a different particle effect. And then this goes on ad infinitum. You can press Space to restart. So we have keyboard input that's based on what we press, different things happen. And so that's effectively the demo that I've put together today. So thanks, Steven. I appreciate you coming up to demo it. So that's the 3D helicopter game. It's got most of the same mechanics as the web version from before-- I would say, maybe even more features just to illustrate a few new concepts. But that's effectively what we're going with today. We're just a pretty simple, Flappy Bird esque differently-themed game, based on the same principles. Fly forever, avoid obstacles. And in this case, even get little collectibles. And so notice that there are also effectively two states in our game, which are just the playing state, and then the game over state. The two are almost effectively the same. The only real difference is that one doesn't have the helicopter present, and displays a different GUI element in the middle of the screen. If you haven't downloaded Unity already, there's two links here. So the top link is just the catchall download link. And then the second link is the beta link. So we're actually using the beta in this course, because Unity has started transitioning away from a numerical system for their releases, and is now going yearly with their releases. So the last long-term release candidate was 2017's version. But now that we're almost halfway through 2018, the newest beta is the 2018 version. It has a bunch of new features. So go ahead and check that out. And everything's been well tested, and runs very well-- very smoothly on Windows and Mac--