Skip to main content
Version: latest - a1.70.x โš–๏ธ

๐Ÿ“บ 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.
๐Ÿง‘โ€๐Ÿ’ปAPI Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

๐Ÿ—ฟ Static Functionsโ€‹

ReturnsNameDescription
Transforms a 2D screen coordinates into 3D world-space location
Vector2DGets the current mouse screen location
Gets the scale of viewport
Vector2DGets the size of viewport
Vector2DTransforms a 3D world-space vector into 2D screen coordinates
Enables/Disables the Blood Screen effect
Manually sets the Blood Screen intensity
Enables/Disables the Crosshair
Loads and sets a hardware cursor in the game from a PNG image
Sets the mouse position

DeprojectScreenToWorld

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

โ€” Returns ().

local ret = Viewport.DeprojectScreenToWorld(screen_position)
TypeParameterDefaultDescription
Vector2Dscreen_position Required parameter Screen position

GetMousePosition

Gets the current mouse screen location

โ€” Returns Vector2D (The current mouse screen location).

local ret = Viewport.GetMousePosition()

See also SetMousePosition.


GetViewportScale

Gets the scale of viewport

โ€” Returns (The scale of viewport).

local ret = Viewport.GetViewportScale()

GetViewportSize

Gets the size of viewport

โ€” Returns Vector2D (The size of viewport).

local ret = Viewport.GetViewportSize()

ProjectWorldToScreen

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

โ€” Returns Vector2D.

local ret = Viewport.ProjectWorldToScreen(world_position)
TypeParameterDefaultDescription
Vectorworld_position Required parameter World 3D position

SetBloodScreenEnabled

Enables/Disables the Blood Screen effect

Viewport.SetBloodScreenEnabled(is_enabled)
TypeParameterDefaultDescription
is_enabled Required parameter No description provided

SetBloodScreenIntensity

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

Viewport.SetBloodScreenIntensity(intensity)
TypeParameterDefaultDescription
intensity Required parameter From 0.0 to 1.0

SetCrosshairEnabled

Enables/Disables the Crosshair

Viewport.SetCrosshairEnabled(is_enabled)
TypeParameterDefaultDescription
is_enabled Required parameter No description provided

SetHardwareCursor

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

Viewport.SetHardwareCursor(cursor_shape, cursor_path, hotspot?)
TypeParameterDefaultDescription
cursor_shape Required parameter No description provided
cursor_path Required parameter a PNG image relative to Assets/
Vector2Dhotspot?Vector(0, 0)No description provided

SetMousePosition

Sets the mouse position

Viewport.SetMousePosition(new_position)
TypeParameterDefaultDescription
Vector2Dnew_position Required parameter No description provided

See also GetMousePosition.

๐Ÿš€ Eventsโ€‹

NameDescription
Called 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