Garry's Mod Wiki

EyePos

Vector EyePos()

Description

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

This function is only reliable inside rendering hooks.

Issue Tracker: 2516

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: 32ms

DB GetPage 3
Generate Html 6
SaveChanges (1) 9
Render Body 0
Render Sidebar 11