I was recently working on my game and I implemented a camera
manager to handle everything that has to do with the camera in my game. My game
is a top down shooter so I only have one camera. We were finalizing what our
first level was going to look like and I had to change the camera to fit the
new proportions. My camera was working fine and I thought that everything was
ok, I was wrong. When I adjusted the camera I quickly found that my camera
logic was flawed. The game was stretched and disproportional and the player was
in the bottom of the screen. It seems that I am rusty on how cameras work. Time
to re-educate!
The first thing I need to get all squared out is what
defines a camera? To me a camera in a game is the viewport that is shown to the
user. It is like the user is looking through the lens of the camera at the
virtual world. I still have the definition right at least in my camera logic so
I can check that off my list of possible errors. Ok now that I have the definition
down I have to get the different types of camera down.
Perspective cameras are cameras that maintain and display
perspective. Perspective is displaying three dimensional objects on a two dimensional
surface. It tries to keep proportions correct in relation to other objects. You
can see in the railway track picture that they railway goes to a point the
farther it is away from the camera. So is a perspective camera set up? A
perspective is made up of a viewing frustum, near and far clipping planes and a
field of view. The picture below demonstrates how all these components are
configured. The view frustum is defined by the bounds of the near and far
clipping planes. The near clipping
plane is smaller than the far clipping plane so this makes the objects seem
bigger the closer they get to the camera. This mirrors how things in the real
world work. Any objects within the view frustum, near and far clipping planes will
be visible to the camera; everything else will be out of the camera view. My
camera is not a perspective camera so some of the camera logic does not apply
to me so let’s check out the other camera.
An orthographic camera does not have a frustum and therefor
does not display perspective. Instead of objects getting smaller the further it
gets from the camera there is no change in the orthographic camera. Instead of
a frustum the camera has a box with left, right, top, and bottom bounds. With a
box instead of a frustum there is no perspective anymore. This is great for top
down games like ours and this is the camera that we are using.
Now that I have been reminded about how the orthographic camera
works my problem would be that I was trying to move the camera forward to zoom
in the camera. This does not work because moving it closer to the camera does
not change its size. Instead I need to change the size of my box to make it smaller
in order to make the player bigger. Now that I have that figured out let’s keep
going and think about how games handle cameras.
Fixed Camera
Every time I think about camera now I think about God of War
as this is my professors go to for everything involving cameras. Now I have
never played the games as I never owned a PlayStation anything before, but from
the countless gameplay footage that I have seen in class I can now talk about its
camera with some knowledge and I have to say that yes it does have a great
camera system. Everything that has to do with the camera is smooth and seamless.
All the camera shots in the cut scenes look like block buster shots. So how do
they do it? To set up something like that would not be too hard to do in a 3D
modeling program like Maya. All of the cut scenes can be done with Maya to
control the camera shots better and more effectively. You can set up locators
in the scene that have a position and orientation. If you have enough of them
you can interpolate between them and have an effective camera system. You can
also set a path or a rail that the camera can follow to control the camera that
way.
Dynamic Cameras
Fixed cameras are much easier to setup and implement than
dynamic camera as there is a lot more logic that has to go in to make a dynamic
camera good. A camera is the window to your game world and as such they greatly
affect the feel and playability of the game. There have been a lot of games
that implement dynamic camera and decrease the playability and the overall feel
of the game. That is why dynamic cameras are much more meticulous to implement.
Then there are easier cameras to implement like the first person camera that
lets you take the perspective of a character in a game. This one is easy to implement
and code but there are others that can make or break a game.
The third person camera is one of these cameras that can
make or break a game as a good implementation can add to the game’s experience.
If it is not done correctly then it can severely hinder the game’s playability
and overall experience. Clipping and colliding
with objects and obstacles are a big concern with third person cameras. There
is a time in every gamer’s carrier where they have been near a wall and the
camera clips or goes into the wall. When this happens it takes away from the
game world and shows the games ugly side that is support to be covered up. One way
to reduce this from happening is to have different types of camera and choose
the right camera for the right occasion. Each camera can have a different
weighting and blending different types of camera could help avoid this problem.
Anyway that are some thoughts about camera now that I have
talked about camera time to go and fix mine!
No comments:
Post a Comment