• How to get the world Pos of a players aiming/looking position, aka geting the position in the world
    6 replies, posted
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?
[lua]pl:GetEyeTrace().HitPos[/lua] HitPos is the vector that the trace ends at.
[QUOTE=KingofBeast;42643079][lua]pl:GetEyeTrace().HitPos[/lua] HitPos is the vector that the trace ends at.[/QUOTE] 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.
[code] pl:GetEyeTrace().HitPos.x pl:GetEyeTrace().HitPos.y pl:GetEyeTrace().HitPos.z [/code] will return the components of the position you can modify them using something simple such as: [code] pl:GetEyeTrace().HitPos.x + Vector(10,0,0) pl:GetEyeTrace().HitPos.y + Vector(0,10,0) pl:GetEyeTrace().HitPos.z + Vector(0,0,10) [/code]
[QUOTE=cabbiethefirst;42643477][code] pl:GetEyeTrace().HitPos.x pl:GetEyeTrace().HitPos.y pl:GetEyeTrace().HitPos.z [/code] will return the components of the position you can modify them using something simple such as: [code] pl:GetEyeTrace().HitPos.x + Vector(10,0,0) pl:GetEyeTrace().HitPos.y + Vector(0,10,0) pl:GetEyeTrace().HitPos.z + Vector(0,0,10) [/code][/QUOTE] That's not how lua works. [code] local offset = Vector(10,10,10) local vec = pl:GetEyeTrace().HitPos + offset print(vec) [/code]
[QUOTE=dingusnin;42643776]That's not how lua works. [code] local offset = Vector(10,10,10) local vec = pl:GetEyeTrace().HitPos + offset print(vec) [/code][/QUOTE] 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!
Sorry, you need to Log In to post a reply to this thread.