Fandom

CraftStudio Wiki

Scripting Reference/Camera

< Scripting Reference

56pages on
this wiki
Add New Page
Comments0 Share

Camera:SetProjectionMode, Camera:GetProjectionModeEdit

Camera:SetProjectionMode( [ProjectionMode] projection mode )
[ProjectionMode] Camera:GetProjectionMode()

Sets or returns the camera projection mode. Possible values are: Camera.ProjectionMode.Perspective and Camera.ProjectionMode.Orthographic.

Camera:SetFOV, Camera:GetFOVEdit

​Camera:SetFOV( [number] fov )
[number] ​Camera:GetFOV()

Sets or returns the camera's vertical angle of view (also called Field of view), in degrees. Valid values are 1° to 179°.

Only used when the camera's projection mode is perspective.

Camera:SetOrthographicScale, Camera:GetOrthographicScaleEdit

​Camera:SetOrthographicScale( [number] scale )
[number] Camera:GetOrthographicScale()

Sets or returns the camera's orthographic scale. The bigger the scale, the bigger the camera's viewing area will be.

Only used when the camera's projection mode is orthographic.

Camera:SetRenderViewportPosition / Camera:SetRenderViewportSize, Camera:GetRenderViewportPosition / Camera:GetRenderViewportSize, Edit

Camera:SetRenderViewportPosition( [number] x, [number] y )
Camera:SetRenderViewportSize( [number] width, [number] height )

[table] Camera:GetRenderViewportPosition()
[table] Camera:GetRenderViewportSize()

Sets or returns the camera's render viewport position and size. This can be used to setup split-screen multiplayer.

The values are normalized, that means they should be within the 0.0 to 1.0 range.

For instance, you could have two cameras with size (1.0, 0.5). One at the top located at (0, 0) and the other one at the bottom located at (0, 0.5).

The returned tables for the getters contain two numbers stored as the x and y properties.

Camera:CreateRayEdit

[Ray] Camera:CreateRay( [table] position )

Creates a Ray starting from the camera at the specified (X, Y) screen coordinates and going forward.

It can be used to implement mouse picking and other similar actions. See this raycasting demo video for instance.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.