The camera objects in YAHAHA are like windows into the 3D game world, offering different perspectives and views of the action. You can add multiple cameras to your scene, but only one can be active at any given time, acting as the game's "eye" on the world.
The camera object's properties play a crucial role in defining the view and exploration of the 3D game world. The following are the most important properties:
- The Virtual Camera Name property identifies a virtual camera.
- The Camera Mode property offers pre-built camera options.
- The FOV property represents the extent of the observable world visible.
- The Follow Target property determines the target for the camera to follow.
- The LookAt Target property determines the target for the camera to stay focused on.
- The Enable Physics property controls whether the camera's collider is active.
How to work with the camera¶
In each new project based on a template, a virtual camera named Default is automatically created. Similar to a camera in a 3D RPG, it provides a third-person perspective by following the player character from behind. It supports zooming, rotation around an avatar, and will be squeezed out when near colliders.
To create a camera:
For a quick setup, select a camera component from Asset Library, such as RTS, side-scroll, or top-down to easily get started.
For advanced configuration, use the camera module in Advanced Mode.
When using a camera component from Asset Library, it automatically generates a Default camera that cannot be renamed. To prevent conflicts, always remove any existing Default cameras added using camera components before creating a new one.
If you prefer more customization options, the camera module provides additional features. In addition to the Default camera, there are two built-in cameras named Gun and Car. You also have finer control of the camera. For instance, you can set the Camera Mode to EntityControl and use scripts to modify the attached object's transform, thereby controlling the camera's position and orientation.
-- Client script :: When a trigger zone is activated, blend to the camera attached to the zone in 2 seconds
local self = script:SelfEntity()
local character = YaScene:GetComponent(script:GetComponentType("YaCharacterComponent"), entity)
if character== nil then
You can also set a new camera's name to Default in order to override the default camera's property values, thus offering a different game perspective.
Four example cameras configured using the camera module in Advanced Mode:
Note: If you set Min Distance, Max Distance, and Default Distance all to 0, and toggle off Enable Physics, you will get a first-person shooter (FPS) camera. This camera allows you to experience the game world from the perspective of the character, as if you were looking through their eyes.
The camera's transform dynamically tracks an object's movement and rotation.
|Game view 1
|Game view 2
For more information on the camera module, see Camera module.
To learn how to use camera components from Asset Library, see Working with the camera.