Struct Camera

Camera node, displays from a point of view.

struct Camera ;

Camera is a special node that displays what is visible from its current location. Cameras register themselves in the nearest Viewport node (when ascending the tree). Only one camera can be active per viewport. If no viewport is available ascending the tree, the camera will register in the global viewport. In other words, a camera just provides 3D display capabilities to a Viewport, and, without one, a scene registered in that Viewport (or higher viewports) can't be displayed.

Properties

NameTypeDescription
cullMask[get, set] longThe culling mask that describes which 3D render layers are rendered by this camera.
current[get, set] boolIf true, the ancestor Viewport is currently using this camera.
dopplerTracking[get, set] Camera.DopplerTrackingIf not constant DOPPLER_TRACKING_DISABLED, this camera will simulate the url=https://en.wikipedia.org/wiki/Doppler_effectDoppler effect/url for objects changed in particular _process methods. See dopplertracking for possible values.
environment[get, set] EnvironmentThe Environment to use for this camera.
far[get, set] doubleThe distance to the far culling boundary for this camera relative to its local Z axis.
fov[get, set] doubleThe camera's field of view angle (in degrees). Only applicable in perspective mode. Since keepAspect locks one axis, fov sets the other axis' field of view angle.
frustumOffset[get, set] Vector2The camera's frustum offset. This can be changed from the default to create "tilted frustum" effects such as url=https://zdoom.org/wiki/Y-shearingY-shearing/url.
hOffset[get, set] doubleThe horizontal (X) offset of the camera viewport.
keepAspect[get, set] Camera.KeepAspectThe axis to lock during fov/size adjustments. Can be either constant KEEP_WIDTH or constant KEEP_HEIGHT.
near[get, set] doubleThe distance to the near culling boundary for this camera relative to its local Z axis.
projection[get, set] Camera.ProjectionThe camera's projection mode. In constant PROJECTION_PERSPECTIVE mode, objects' Z distance from the camera's local space scales their perceived size.
size[get, set] doubleThe camera's size measured as 1/2 the width or height. Only applicable in orthogonal mode. Since keepAspect locks on axis, size sets the other axis' size length.
vOffset[get, set] doubleThe vertical (Y) offset of the camera viewport.

Methods

NameDescription
clearCurrent If this is the current camera, remove it from being current. If enable_next is true, request to make the next camera current, if any.
getCameraRid Returns the camera's RID from the VisualServer.
getCameraTransform Gets the camera transform. Subclassed cameras such as InterpolatedCamera may provide different transforms than the Node transform.
getCullMask
getCullMaskBit Returns true if the given layer in the cullMask is enabled, false otherwise.
getDopplerTracking
getEnvironment
getFov
getFrustum Returns the camera's frustum planes in world-space units as an array of Planes in the following order: near, far, left, top, right, bottom. Not to be confused with frustumOffset.
getFrustumOffset
getHOffset
getKeepAspectMode
getProjection
getSize
getVOffset
getZfar
getZnear
isCurrent
isPositionBehind Returns true if the given position is behind the camera. Note: A position which returns false may still be outside the camera's field of view.
makeCurrent Makes this camera the current camera for the Viewport (see class description). If the camera node is outside the scene tree, it will attempt to become current once it's added.
projectLocalRayNormal Returns a normal vector from the screen point location directed along the camera. Orthogonal cameras are normalized. Perspective cameras account for perspective, screen width/height, etc.
projectPosition Returns the 3D point in worldspace that maps to the given 2D coordinate in the Viewport rectangle on a plane that is the given z_depth distance into the scene away from the camera.
projectRayNormal Returns a normal vector in worldspace, that is the result of projecting a point on the Viewport rectangle by the camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking.
projectRayOrigin Returns a 3D position in worldspace, that is the result of projecting a point on the Viewport rectangle by the camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking.
setCullMask
setCullMaskBit Enables or disables the given layer in the cullMask.
setCurrent
setDopplerTracking
setEnvironment
setFov
setFrustum Sets the camera projection to frustum mode (see constant PROJECTION_FRUSTUM), by specifying a size, an offset, and the z_near and z_far clip planes in world-space units.
setFrustumOffset
setHOffset
setKeepAspectMode
setOrthogonal Sets the camera projection to orthogonal mode (see constant PROJECTION_ORTHOGONAL), by specifying a size, and the z_near and z_far clip planes in world-space units. (As a hint, 2D games often use this projection, with values specified in pixels.)
setPerspective Sets the camera projection to perspective mode (see constant PROJECTION_PERSPECTIVE), by specifying a fov (field of view) angle in degrees, and the z_near and z_far clip planes in world-space units.
setProjection
setSize
setVOffset
setZfar
setZnear
unprojectPosition Returns the 2D coordinate in the Viewport rectangle that maps to the given 3D point in worldspace.

Enums

NameDescription
Constants
DopplerTracking
KeepAspect
Projection