How to get the world Pos of a players aiming/looking position, aka geting the position in the world he is looking at?

Pretty much as it says, I cant figure out what I have to use, it is a swep that I am working on, perhaps GetShootPos would work, but how?


HitPos is the vector that the trace ends at.

Hey thanks for the reply man, but if I may ask, is there a way to break it down so I can alter the position to ensure that the player wont get stuck?

Like, adding 20 to hight and exracting 50 from the distance (X,Y) etc.

If you’re looking for a teleport style code, look at the ulx teleport module. That should push you where you want in terms of code.


will return the components of the position

you can modify them using something simple such as:

pl:GetEyeTrace().HitPos.x + Vector(10,0,0)
pl:GetEyeTrace().HitPos.y + Vector(0,10,0)
pl:GetEyeTrace().HitPos.z + Vector(0,0,10)

That’s not how lua works.

local offset = Vector(10,10,10)
local vec = pl:GetEyeTrace().HitPos + offset

Yeah I saw that later on.
I got it working tough!

[editline]25th October 2013[/editline]

Thanks to everyone for their help! I got it working!