Raised This Month: $ Target: $400
 0% 

Vectors - calculating position in front of a player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
t3hNox
Senior Member
Join Date: Oct 2009
Old 06-25-2011 , 15:24   Vectors - calculating position in front of a player
Reply With Quote #1

I know that this problem has been already discussed, but I just can't find any useful topic about it.
I'm looking for a piece of code that can calculate origin, let's say, 40.0 units in front of a player. Height should be also observed (start point is a player, end point is the point where the player is aiming). It's probably some traceline function + xs, but I can't find any reference to xs functions therefore I don't know how to use them.
t3hNox is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-26-2011 , 14:49   Re: Vectors - calculating position in front of a player
Reply With Quote #2

Something simple:
Code:
new iEyesOrigin[ 3 ]; get_user_origin( iPlayer, iEyesOrigin, 1 ); new Float:vecEyesOrigin[ 3 ]; IVecFVec( iEyesOrigin, vecEyesOrigin ); new Float:vecDirection[ 3 ]; velocity_by_aim( iPlayer, 40, vecDirection ); new Float:vecAimOrigin[ 3 ]; xs_vec_add( vecEyesOrigin, vecDirection, vecAimOrigin ); // vecAimOrigin has 40 units away from where player is aiming
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
t3hNox
Senior Member
Join Date: Oct 2009
Old 06-27-2011 , 08:06   Re: Vectors - calculating position in front of a player
Reply With Quote #3

Thank you, Exolent.
I tried to make some calculations myself but they didn't work correctly. This, on the other hand, seems to be working properly.

Last edited by t3hNox; 06-27-2011 at 08:11.
t3hNox is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode