Returns where on the screen the specified position vector would appear. A related function is gui.ScreenToVector, which converts a 2D coordinate to a 3D direction.
Should be called from a 3D rendering environment or after cam.Start3D or it may not work correctly.
Errors in a render hook can make this value incorrect until the player restarts their game.
Draw some text on certain entities/positions in-world.
hook.Add( "HUDPaint", "ToScreenExample", function() -- Get a list of all props local points = ents.FindByClass( "prop_*" ) -- For each prop, draw a marker on screen for id, ent in pairs( points ) do local point = ent:GetPos() + ent:OBBCenter() -- Gets the position of the entity, specifically the center local data2D = point:ToScreen() -- Gets the position of the entity on your screen -- The position is not visible from our screen, don't draw and continue onto the next prop if ( not data2D.visible ) then continue end -- Draw a simple text over where the prop is draw.SimpleText( "Prop here", "Default", data2D.x, data2D.y, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) end end )