Skip to content

YaVirtualCameraAPI

The YaVirtualCameraAPI static class provides functionality to adjust the player's virtual camera in a game scene.
  • Setting_CameraFixPositionAndOrientation
  • Setting_CameraFixPositionAndViewControllable
  • Setting_CameraFixPositionAndLookAt
  • Setting_CameraTopdown. With this component, the SetCameraPosition and SetCameraOrientation functions are unavailable.
  • Setting_CameraRTS
  • Setting_CameraSideScroll. With this component, the SetCameraPosition and SetCameraOrientation functions are unavailable.
  • Setting_CameraThirdPerson. With this component, the SetCameraPosition function is unavailable.

Functions

float2 YaVirtualCameraAPI.ScreenResolution()

CLIENT ONLY 
Returnsthe screen resolution
Gets the screen resolution. It is represented as (pixelWidth, pixelHeight) in pixels.

float2 YaVirtualCameraAPI.GetScreenSize()

CLIENT ONLY 
Returnsthe screen size
Gets the screen size. It is usually represented as (Width, Height) in world size.

float3 YaVirtualCameraAPI.WorldToScreenPoint(float3 worldPoint)

CLIENT ONLY 
Returnsthe screen position
Converts a position from world space to screen space Screen space is a 2D coordinate system defined by the dimensions of a display. The bottom left corner of the screen space is (0,0), and the top right corner is (pixelWidth, pixelHeight) in pixels. The z position of objects in 3D space can be represented in screen space using a depth value relative to the camera.
  • worldPoint The world position to be converted

float3 YaVirtualCameraAPI.WorldToViewportPoint(float3 worldPoint)

CLIENT ONLY 
ReturnsThe viewport position
Converts a position from world space to viewport space Viewport space is normalized and relative to the camera. The bottom left corner corner of the viewport space is (0,0), and the top right corner is (1, 1). The z position of objects in 3D space can be represented in viewport space using a depth value relative to the camera.
  • worldPoint The world position to be converted

float3 YaVirtualCameraAPI.ViewportToWorldPoint(float3 viewport)

CLIENT ONLY 
ReturnsThe world position
Converts a position from viewport space to world space Viewport space is normalized and relative to the camera. The bottom left corner corner of the viewport space is (0,0), and the top right corner is (1, 1). The z position of objects in 3D space can be represented in viewport space using a depth value relative to the camera.
  • viewport The viewport position to be converted

float3 YaVirtualCameraAPI.ScreenToWorldPoint(float3 screen)

CLIENT ONLY 
ReturnsThe world position
Converts a position from screen space to world space Screen space is a 2D coordinate system defined by the dimensions of a display. The bottom left corner of the screen space is (0,0), and the top right corner is (pixelWidth, pixelHeight) in pixels. The z position of objects in 3D space can be represented in screen space using a depth value relative to the camera.
  • screen The screen position to be converted

float3 YaVirtualCameraAPI.GetCameraPositionFromServer(YaEntity targetPlayer)

SERVER ONLY 
Returnsposition
Gets the current position of the virtual camera being used by the specified player entity or avatar entity that the player is controlling The position value is calculated based on the previous frame.
  • targetPlayer The player entity or avatar entity that player is controlling

float3 YaVirtualCameraAPI.GetCameraEulerFromServer(YaEntity targetPlayer)

SERVER ONLY 
Returnsthe camera's rotation as Euler angles
Gets the target player's virtual camera's rotation as Euler angles in degrees The rotation value is calculated based on the previous frame.
  • targetPlayer The player entity or avatar entity that player is controlling

void YaVirtualCameraAPI.SetCameraDamping(float3 dampingXYZ)

CLIENT ONLY 
Sets the current virtual camera damping values for its x-, y-, and z- axes. Only works when you use a third-person virtual camera.
  • dampingXYZ The damping values for the camera's x-, y-, and z- axes

float3 YaVirtualCameraAPI.GetCameraDamping()

CLIENT ONLY 
Returnsthe damping values for the camera's x-, y-, and z- axes
Gets current virtual camera's damping values for its x-, y-, and z- axes

float3 YaVirtualCameraAPI.GetCameraEuler()

CLIENT ONLY 
ReturnsThe camera's rotation as Euler angles
Gets the local player's current virtual camera's rotation as Euler angles in degrees The rotation value is calculated based on the previous frame.

void YaVirtualCameraAPI.SetCameraTransform(float3 position, float3 eulerAngle)

CLIENT ONLY 
Sets the current virtual camera's position and rotation Only works when the camera has no tartget to look at or follow and view is not controllable.
  • position The camera's position in world space
  • eulerAngle The camera's rotation as Euler angles

void YaVirtualCameraAPI.SetCameraEuler(float3 eulerAngle)

CLIENT ONLY 
Sets the current virtual camera's rotation in world space as Euler angles Only works when the virtual camera has no target to look at and view is not controllable. Note that when you use a third person virtual camera and have a target to follow, changing the virtual camera's rotation via this API will affect its position. To avoid such effect, use SetCameraTransform instead.
  • eulerAngle The camera's rotation as Euler angles

float3 YaVirtualCameraAPI.GetCameraEulerOffset()

CLIENT ONLY 
ReturnsThe rotational offset in camera space
Returns the rotational offset of the current virtual camera in camera space, which represents the difference between the camera's actual rotation in world space and its desired rotation. Camera space is the coordinate system where the camera is positioned at the origin(0,0,0), and objects are rendered relative to the camera's viewpoint.

void YaVirtualCameraAPI.SetCameraEulerOffset(float3 eulerAngleOffset)

CLIENT ONLY 
Sets the rotational offset of the current virtual camera in camera space, which represents the difference between the camera's actual rotation in world space and its desired rotation. Camera space is the coordinate system where the camera is positioned at the origin(0,0,0), and objects are rendered relative to the camera's viewpoint.
  • eulerAngleOffset The rotational offset in camera space

float3 YaVirtualCameraAPI.GetCameraPosition()

CLIENT ONLY 
Returnsthe position of the camera
Gets the current position of the current virtual camera in world space The position value is calculated based on the previous frame.

float3 YaVirtualCameraAPI.GetCameraOffset()

CLIENT ONLY 
Returnsthe camera offset from target
Gets the offset of the current virtual camera from its target in camera space. Camera space is the coordinate system where the camera is positioned at the origin(0,0,0), and objects are rendered relative to the camera's viewpoint.

void YaVirtualCameraAPI.SetCameraOffset(float3 offset)

CLIENT ONLY 
Sets the offset of the current virtual camera from its target in camera space Camera space is the coordinate system where the camera is positioned at the origin(0,0,0), and objects are rendered relative to the camera's viewpoint.
  • offset The camera offset from target in camera space

void YaVirtualCameraAPI.SetCameraPosition(float3 position)

CLIENT ONLY 
Sets the position of the current virtual camera in world space Only works when the camera has no target to look at or follow and view is not controllable.
  • position The position to set the camera to in world space

void YaVirtualCameraAPI.SetCameraFollowTarget(YaEntity entity)

CLIENT ONLY 
Sets the target for the current virtual camera to follow. This method will not take effect in the Fixed camera mode.
  • entity The target for the camera to follow

void YaVirtualCameraAPI.SetCameraLookAtTarget(YaEntity entity)

CLIENT ONLY 
Sets the target for the current virtual camera to look at.
  • entity The target for the camera to look at

void YaVirtualCameraAPI.SetCameraLookAtOffset(float3 lookAtOffset)

CLIENT ONLY 
Sets the offset for the current virtual camera's target to look at, adjusting its position relative to the camera in the target's local space.
  • lookAtOffset The offset to set in the local space of the target for the camera to look at

void YaVirtualCameraAPI.SetCameraDistance(number distance)

CLIENT ONLY 
Sets the distance for the current virtual camera to move along the z-axis. Only works when you use a third-person, sidescroll, rts, or topdown camera. If the specified distance exceeds the set distance interval, the specified distance will take effect.
  • distance The distance to set along the z-axis

void YaVirtualCameraAPI.SetCameraOrthographicSize(number size)

CLIENT ONLY 
Changes the orthographic size of the current virtual camera
  • size The new orthographic size to set for the camera

number YaVirtualCameraAPI.GetCameraOrthographicSize()

CLIENT ONLY 
ReturnsThe current orthographic size of the camera
Gets the current orthographic size of the current virtual camera.

void YaVirtualCameraAPI.SetCameraViewControllable(boolean controllable)

CLIENT ONLY 
Determines if the current virtual camera view is controllable.
  • controllable If true, the camera view is controllable; if false, the camera view is uncontrollable. It can be set with the Third Person, FixPositionAndViewControllable, or RTS\SideScroll\TopDown component.

void YaVirtualCameraAPI.SetCameraZoomControllable(boolean controllable)

CLIENT ONLY 
Determines if the current virtual camera zoom is controllable.Fix Mode will not effect.
  • controllable If true, the camera zoom in out is controllable

number YaVirtualCameraAPI.GetFov()

CLIENT ONLY 
ReturnsThe field of view of the camera in degrees
Returns the current virtual camera's field of view (FOV) on the client side.

void YaVirtualCameraAPI.SetFov(number fov)

CLIENT ONLY 
Sets the current virtual camera's field of view (FOV) value. The FOV must be between 1 and 179 degrees. If a value higher than 179 is specified, the FOV will be clamped to 179. If a value smaller than 1 is specified, the FOV will be clamped to 1.
  • fov The field of view of the camera in degrees

float2 YaVirtualCameraAPI.GetNearFarClippingPlane()

CLIENT ONLY 
Returnsnearest distance(x) and furthest distance(y) of frustum plane
Return the near and far plane of the current virtual camera's viewing frustum.

void YaVirtualCameraAPI.SetNearFarClippingPlane(number nearPlane, number farPlane)

CLIENT ONLY 
Adjusts the near and far plane of the current virtual camera's viewing frustum.
  • nearPlane nearest distance of frustum plane
  • farPlane furthest distance of frustum plane

void YaVirtualCameraAPI.ActiveCameraByEntity(YaEntity vCameraEntity, number blendTime)

CLIENT ONLY 
Blends the current virtual camera to the target virtual camera from entity that the Camera component is attached to
  • vCameraEntity The unique identifier of the entity that contains the Camera component. Entity ID can be found in Advanced Mode.
  • blendTime The time in seconds to blend to the new camera

void YaVirtualCameraAPI.ActiveCameraByName(string vCameraName, number blendTime)

CLIENT ONLY 
Blends the current virtual camera to the target virtual camera created via the Camera component by name
  • vCameraName The name of the camera created via the Camera component
  • blendTime The time in seconds that the current camera blends to the new camera

void YaVirtualCameraAPI.ResetCameraByName(string vCameraName)

CLIENT ONLY 
Resets the virtual camera's data by virtual camera name
  • vCameraName The name of the virtual camera

void YaVirtualCameraAPI.ResetCameraByEntity(YaEntity vCameraEntity)

CLIENT ONLY 
Resets the virtual camera's data using the entity that the Camera component is attached to
  • vCameraEntity The name of the entity that the Camera component is attached to

void YaVirtualCameraAPI.SetCameraPhysicsEnable(boolean enable)

CLIENT ONLY 
Enables or disables current virtual camera collisions. In the Fixed camera mode, the collider will not affect camera movement
  • enable If true, camera collisions are enabled. If false, camera collisions disabled.