EyePos

From Garry's Mod
Jump to: navigation, search
 EyePos( )

Contents

Description

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

BUG

This function is only reliable inside rendering hooks.

Issue Tracker: #2516

Returns

Vector

Camera position.

Examples

Example

Print the view position

print(EyePos())


Examples

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.
Personal tools
Navigation