Camera
Overview
In a game, the camera provides a virtual viewpoint or perspective that allows players to observe and interact with the game world. Like a real-world camera, the game camera is a crucial tool that conveys the virtual environment, character actions, and events to the player, significantly influencing the game’s immersion and player enjoyment.
The camera goes beyond simply illuminating a scene; it uses various techniques such as movement and rotation to deliver a rich experience to the player. By emphasizing visual effects or dramatically showcasing specific events, it maximizes the game’s atmosphere and immersion. It is also a tool for effectively conveying various intended experiences, as well as interactions between characters and the environment.
The camera’s perspective can completely change the way a game is played. For example, in shooter games, the camera perspective can provide entirely different gameplay experiences:
Top-Down View (TOP-View): Simple aiming and shooting makes it suitable for fast-paced action.
TPS (Third-Person Perspective) / FPS (First-Person Perspective): Requires more precise vision and tactical play, enhancing immersion in combat.
Thus, the camera’s perspective is not just a visual tool but a critical element that can alter the core fun and strategy of a game.
Properties
CFrame
The camera’s position and orientation
Focus
The position and direction (of the subject) the camera is looking at
FieldOfView
The camera’s field of view (0 < FOV < 180)
ViewportSize
The size of the screen viewed through the camera
CameraSubject
The object the camera is focused on
CameraType
The type of camera
How to Use the Camera
Modifying Camera Properties
To directly adjust the camera, you need to edit the settings through scripting. While you can temporarily change values using the properties provided in the editor, actual camera settings must be applied through code (script) to reflect the changes.
Specifying Camera Type
The camera can currently only be manipulated for Custom and Scriptable types.
CFrame or Focus will not be modified unless the camera type is Scriptable, they are automatically determined by the default camera type.
Using the Scriptable type allows for more detailed adjustments and control.
Zooming In/Out Using FieldOfView and CFrame
FieldOfView is a key property for adjusting the camera’s field of view. It can be used to implement various custom camera effects:
Reducing FOV provides a Zoom-In effect.
Increasing FOV creates a **Wide-Angle **effect, similar to shooting with a wide-angle lens.
There are two ways to implement zooming in/out for your subject (e.g., the player):
Camera Position Adjustment: Moving the camera forward or backward to achieve the zoom effect.
FieldOfView Adjustment: Changing the field of view to implement zooming, which may introduce screen distortion.
Each method has its own characteristics, so the choice depends on the implementation goal. For example, to minimize distortion, use camera movement; for a stylish effect, use FOV adjustment.
🎥 Below are examples of zoom effects applied to the same subject using both methods:
Camera Movement Method: Natural zooming in and out.
When zooming in/out, objects closer to the camera scale more noticeably, while distant objects show little change in size.
FOV Adjustment Method: Distorted spatial perception when zooming in and out.
When zooming in/out, both near and distant objects scale similarly.
When zooming in, distant objects appear closer, creating a distorted effect.
If you look at the zoomed-in state, the size of the trees in the background behind the character doesn’t change much with the camera movement method, whereas with the FOV method, the trees in the background seem much larger and closer.
In the zoomed out state, you can see that the size change of the trees is not noticeable when the camera is moved, while the background size seem much smaller when the FOV is changed.
When the field of view is increased to a significant level, the screen exhibits severe distortion at the edges, similar to a fish-eye lens effect.
Setting CameraSubject
The CameraSubject property specifies the subject the camera focuses on.
By default, this is set to the player character.
You can assign specific objects as the subject to create various effects.
The camera movement that is locked to a Part position. The camera no longer follows the character.
Usage Examples
Top-down View Camera
The top-down view camera has the following characteristics:
Provides a bird’s-eye view, looking down at the character from above.
The camera follows the character at all times, keeping them centered or at a specific position on the screen.
The camera does not rotate regardless of the character’s movement, reducing fatigue or motion sickness.
Offers a wide field of view, suitable for tactical and strategic games.
However, it can lead to a monotonous game screen, which can be boring.
Typically, a player positioned higher on the screen can hide their character behind a wall, while it is difficult for a lower-positioned player to spot them.
To implement a top-down view, the following functionalities must be completed:
Using a Scriptable Camera to always track the player character’s position
Updating the camera’s position and viewing angle based on the character’s position
TPS Camera
Offers a perspective close to first-person while allowing the player to see their own character.
The camera’s view remains clear even if the character’s body is blocked by objects, providing an open and unobstructed feel.
Provides a broader field of view compared to FPS cameras while supporting free camera rotation.
Provides long-distance visibility, allowing players to see distant objects clearly.
However,
The camera’s direction (or crosshair) may not align with the character’s direction. In shooting games, this requires additional handling to ensure accurate targeting.
(For example, while the crosshair may show an enemy clearly, the character’s position might be blocked by walls or objects, making it impossible to hit the target)
Players can hide behind walls, remaining hidden from their opponent’s view while still being able to see their opponent. This kind of information asymmetry can lead to unfair gameplay in PvP scenarios.
The TPS camera can be positioned by specifying an offset, similar to a top-down view camera. However, unlike a top-down view, the TPS camera requires camera rotation to be implemented.
Always acquire the player’s position with the scriptable camera
Move the camera based on character position and apply offset
When rotating the camera, treat the camera as if it is moving along the surface of a virtual sphere centered on the character
Last updated