Skip to main content

Viewport

Work with screen properties and effects.

🗿Static Class
This is a Static Class. Access it's methods directly with .. It's not possible to spawn new instances.
💂Authority
This static class can be accessed only on 🟧 Client side.

Static Functions

ReturnsNameDescription
Vector2DProjectWorldToScreenTransforms a 3D world-space vector into 2D screen coordinates
tableDeprojectScreenToWorldTransforms a 2D screen coordinates into 3D world-space location
SetHardwareCursorLoads and sets a hardware cursor in the game from a PNG image
Vector2DGetViewportSizeGets the size of viewport
SetMousePositionSets the mouse position
Vector2DGetMousePositionGets the current mouse screen location
SetCrosshairEnabledEnables/Disables the Crosshair
SetBloodScreenEnabledEnables/Disables the Blood Screen effect
SetBloodScreenIntensityManually sets the Blood Screen intensity

ProjectWorldToScreen

Transforms a 3D world-space vector into 2D screen coordinates

— Returns Vector2D.

local ret = Viewport.ProjectWorldToScreen(world_position)
TypeParameterDefaultDescription
Vectorworld_positionWorld 3D position

DeprojectScreenToWorld

Transforms a 2D screen coordinates into 3D world-space location

— Returns table (with this format).

local ret = Viewport.DeprojectScreenToWorld(screen_position)
TypeParameterDefaultDescription
Vector2Dscreen_positionScreen position

SetHardwareCursor

Loads and sets a hardware cursor in the game from a PNG image

Viewport.SetHardwareCursor(cursor_shape, cursor_path, hotspot?)
TypeParameterDefaultDescription
CursorTypecursor_shape
Image Pathcursor_patha PNG image relative to Assets/
Vector2Dhotspot?Vector(0, 0)

GetViewportSize

Gets the size of viewport

— Returns Vector2D (The size of viewport).

local ret = Viewport.GetViewportSize()

SetMousePosition

Sets the mouse position

Viewport.SetMousePosition(new_position)
TypeParameterDefaultDescription
Vector2Dnew_position

GetMousePosition

Gets the current mouse screen location

— Returns Vector2D (The current mouse screen location).

local ret = Viewport.GetMousePosition()

SetCrosshairEnabled

Enables/Disables the Crosshair

Viewport.SetCrosshairEnabled(is_enabled)
TypeParameterDefaultDescription
booleanis_enabled

SetBloodScreenEnabled

Enables/Disables the Blood Screen effect

Viewport.SetBloodScreenEnabled(is_enabled)
TypeParameterDefaultDescription
booleanis_enabled

SetBloodScreenIntensity

If you want the Blood Screen to do not be overridden, disable it with Client.SetBloodScreenEnabled(false) before

Viewport.SetBloodScreenIntensity(intensity)
TypeParameterDefaultDescription
floatintensityFrom 0.0 to 1.0

Events

NameDescription
ResizeCalled when the screen is resized

Resize

Called when the screen is resized
Viewport.Subscribe("Resize", function(new_size)
-- Resize was called
end)
TypeArgumentDescription
Vector2Dnew_sizeNew new screen size