字幕表 動画を再生する
-
[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--
-
with the new beta.
-
So what is Unity?
-
The difference between what we've done so far and what we're doing today is,
-
now we're actually using a full-fledged game engine--
-
this system.
-
It's got a built in editor and all this awesome, cool
-
functionality that we really didn't get with Love2D before.
-
What we were doing before was using a framework,
-
and just implementing everything purely in code.
-
And as we'll see today, everything that you want to do that's customizable
-
effectively is--
-
or can be-- done via code.
-
But there are a lot of more efficient and more user-friendly
-
ways to accomplish the same thing, which we'll take a look at.
-
So Unity has a tremendous market share right now.
-
I forget.
-
I think in 2016 it had like 43% of all games released were done in Unity.
-
I don't know what the current numbers are.
-
I couldn't find them.
-
But there are other engines that are also very well used--
-
Unreal being among them.
-
And Unreal actually may have more market share now,
-
because of games like Fortnite, and because it's
-
been improved a lot over the last couple of years, and really marketed well.
-
But Godot, CryEngine-- there are a lot of game engines
-
that are similar to this that provide you
-
this all-encompassing way of dealing with your game scene
-
and with all your game data.
-
But Unity is a very easy engine to start getting used to,
-
and cranking things out, and being productive with,
-
without the tremendous learning curve that some
-
of the other engines like Unreal might have.
-
Unreal does have a more user-friendly way of doing things.
-
But if you want to get down into the nitty gritty with Unreal,
-
you're coding in semi-arcane C++.
-
So for folks who aren't used to it and aren't used to 3D game development,
-
it can be kind of a large board to get onto.
-
The nice thing about Unity, aside from the fact
-
that it's fairly easy to get started with, is that it's free.
-
And you can use it completely with all of its features
-
until you start making over $100,000 in gross revenue releasing Unity products.
-
And then there are other tiers.
-
The next tier above that is if you start making $200,000,
-
and you get new features with these other tiers.
-
But if you want to just start up a new company,
-
and use Unity, and take something to market--
-
completely free to do so.
-
And once you get over $100,000, that's a good problem to have.
-
It's not necessarily too much to ask to start
-
paying Unity to use it as a means of getting
-
onto the market in the first place.
-
And especially in mobile and VR, Unity's sort of like the forefront.
-
It's got even higher percentage.
-
It's like 60-something or 70% market share on mobile.
-
And then VR-- from the beginning, it's marketed itself very strongly
-
towards the use of VR.
-
And we'll actually use VR in the next lecture.
-
And the way in which we will accomplish all of the programmatic aspect
-
of this-- getting things actually implemented in code--
-
is via C#, which is very different than what we've used so far,
-
which we've used Lua, which is a dynamic scripting language,
-
very much like JavaScript.
-
So C# is very similar to Java, in which things actually have types.
-
And so here's a couple of screenshots of what the Unity editor looks like.
-
So the nice thing about the Unity editor, actually--
-
which we can see right off the gate here--
-
is that it's very customizable.
-
So on the top, that's the default view.
-
You have a bottom panel that shows you all your resources,
-
all your assets, things like scripts, and shaders, and models,
-
and textures, and sounds.
-
You have a nice file browser there on the left-hand side, which allows
-
you to easily navigate your project.
-
You don't have to go looking through your Windows or Mac computer, using