Lecture Cameras
Lecture Cameras
Lecture: Cameras
Cameras
Cameras are essentially the players view into the world you have created for
them. They provide (the players) with perspective and control how things appear
to them.
As you have already noticed, a Camera (name Main Camera) is created by
default every time you create a new scene. By customizing and manipulating
cameras, you can make the presentation of your game truly unique.
Cameras can be customized, scripted, or parented to achieve just about any kind
of effect imaginable.
> For a puzzle game, you might keep the Camera static for a full view of the
puzzle.
> For a first-person shooter, you would parent the Camera to the player
character, and place it at the character’s eye level.
> For a racing game, you’d probably have the Camera follow your player’s
vehicle
and so forth.
Cameras
You can create multiple cameras in the scene.
Every scene in Unity needs to have a camera, or nothing will be shown.
When having multiple cameras, the Depth parameter controls the order
in which the cameras draw the scene. If the values are different, the camera
with the lower Depth value will be drawn first. If the values are equal, the
first camera added to the scene will be drawn first.
Note that all cameras actually draw the scene, but the last one overrides
all the others if its Clear Flags is not set to Depth Only.
Using Multiple Cameras in a Scene
The camera with Clear Flags = Depth Only only draws those objects hit by
the camera. The rest is not drawn.
Using Multiple Cameras in a Scene
Split Screen: 2 cameras drawing in different parts of the viewport. They can
both be assigned to the same Depth, as they are not overriding each other. In
order to indicate which parts of the viewport each camera draws, modify the
Viewport Rect attribute of the cameras.
fig.1 fig.2
Exercise: Multiple Cameras- Split Screen
In order to achieve a Split Screen effect we have to fiddle with the Normalized View Port
Rect property. The normalized view port basically treats the screen as a simple rectangle.
The lower-left corner of the rectangle is (0, 0) and the upper-right corner is (1, 1). Think
of the coordinates as percentages of the actual size.
So, a coordinate of 1 means 100%, and a coordinate of .5 means 50%.
By default, cameras project from (0, 0) with a width and height of 1 (or 100%), in sort,
they see the whole screen by-default.
• Continue working in the previous scene.
• Change the depth of the Main Camera back to –1.
• X and Y properties of the camera’s View Port Rect property should both be 0.
• Set the W to 1 and H to 0.5.
• The second camera must also have a depth of –1.
• Set the X and Y properties of the view port to (0, .5).
• This will cause the camera to begin drawing halfway down the screen.
• Set the W to 1 and H to 0.5.
• Run the scene and notice how both cameras are now projecting on the
screen at the same time. Using the same steps try splitting the screen one
more time (cut it in 3 sections).
Exercise: Multiple Cameras- Split Screen
Exercise: Camera – Picture-in-Picture
• Hour 6, Sams Teach Yourself Unity Game Development in 24 Hours by Ben Tristem
and Mike Geig