Garry's Mod Wiki

Garry's Mod Wiki

  number util.PixelVisible( Vector position, number radius, pixelvis_handle_t PixVis )

Description

Returns the visibility of a square that is always pointed at the camera in the world-space.

Arguments

1 Vector position
The center of the visibility test.
2 number radius
The radius of the square to check for visibility.
3 pixelvis_handle_t PixVis
The PixVis handle created with util.GetPixelVisibleHandle.
Don't use the same handle twice per tick or it will give unpredictable results.

Returns

1 number
Visibility, ranges from 0-1. 0 when none of the area is visible, 1 when all of it is visible.

Example

Draws a box when the center of the map is visible on your screen.

local PixVis hook.Add( "Initialize", "SetupPixVis", function() PixVis = util.GetPixelVisibleHandle() end ) hook.Add( "HUDPaint", "TestPixelVisibility", function() local visible = util.PixelVisible( Vector( 0, 0, 0 ), 16, PixVis ) if visible and visible ~= 0 then draw.RoundedBox( 10, 0, 0, 100, 100, Color( 0, 0, 0, 200 * visible ) ) end end )

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...