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​
| Returns | Name | Description | |
|---|---|---|---|
| Vector2D | ProjectWorldToScreen | Transforms a 3D world-space vector into 2D screen coordinates | |
| table | DeprojectScreenToWorld | Transforms a 2D screen coordinates into 3D world-space location | |
SetHardwareCursor | Loads and sets a hardware cursor in the game from a PNG image | ||
| Vector2D | GetViewportSize | Gets the size of viewport | |
SetMousePosition | Sets the mouse position | ||
| Vector2D | GetMousePosition | Gets the current mouse screen location | |
SetCrosshairEnabled | Enables/Disables the Crosshair | ||
SetBloodScreenEnabled | Enables/Disables the Blood Screen effect | ||
SetBloodScreenIntensity | Manually sets the Blood Screen intensity |

ProjectWorldToScreen​
Transforms a 3D world-space vector into 2D screen coordinates
— Returns Vector2D.
local ret = Viewport.ProjectWorldToScreen(world_position)
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | world_position | World 3D position |

DeprojectScreenToWorld​
Transforms a 2D screen coordinates into 3D world-space location
— Returns table (with this format).
local ret = Viewport.DeprojectScreenToWorld(screen_position)
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector2D | screen_position | Screen position |

SetHardwareCursor​
Loads and sets a hardware cursor in the game from a PNG image
Viewport.SetHardwareCursor(cursor_shape, cursor_path, hotspot?)
| Type | Parameter | Default | Description |
|---|---|---|---|
| CursorType | cursor_shape | ||
| Image Path | cursor_path | a PNG image relative to Assets/ | |
| Vector2D | hotspot? | 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)
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector2D | new_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)
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | is_enabled |

SetBloodScreenEnabled​
Enables/Disables the Blood Screen effect
Viewport.SetBloodScreenEnabled(is_enabled)
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | is_enabled |

SetBloodScreenIntensity​
If you want the Blood Screen to do not be overridden, disable it with Client.SetBloodScreenEnabled(false) beforeViewport.SetBloodScreenIntensity(intensity)
| Type | Parameter | Default | Description |
|---|---|---|---|
| float | intensity | From 0.0 to 1.0 |
Events​
| Name | Description | |
|---|---|---|
Resize | Called when the screen is resized |

Resize​
Called when the screen is resized
Viewport.Subscribe("Resize", function(new_size)
-- Resize was called
end)
| Type | Argument | Description |
|---|---|---|
| Vector2D | new_size | New new screen size |