Garry's Mod Wiki

EyePos

Description

Returns the origin of the current render context as calculated by GM:CalcView.

This function is only reliable inside rendering hooks.

Returns

1 Vector
Camera position.

Example

Print the view position

print(EyePos())

Example

Ensuring EyePos returns the correct value outside of render hooks.

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, Vector( -5, -5, -5 ), Vector( 5, 5, 5 ) ) end )
Output: Draws a white box in the world where you point the mouse to. Requires the developer convar to be set to 1.

Page Links


Special Pages


Wikis

?

Render Time: 39ms

DB GetPage 4
Generate Html 7
SaveChanges 11
Render Body 0
Render Sidebar 15