EyePos
Vector EyePos()
Description
Returns the origin of the current render context as calculated by GM:CalcView.
Returns
Example
Ensuring EyePos
returns the correct value outside of render hooks.
local mins, maxs = Vector( -5, -5, -5 ), Vector( 5, 5, 5 )
hook.Add( "PreDrawTranslucentRenderables", "FixEyePos", function()
EyePos()
end )
hook.Add( "Think", "Use Eyepos outside of render function", function()
local start = EyePos()
local dir = gui.ScreenToVector( gui.MousePos() )
local trace = util.TraceLine({
start = start,
endpos = start + ( dir * 10000 ),
filter = { ply }
})
debugoverlay.Box( trace.HitPos, mins, maxs )
end )
Output: Draws a white box in the world where you point the mouse to. Requires the developer convar to be set to
1
.