• What is the difference between Player:GetAimVector( ) and Player:GetShootPos( ) when performing a hu
    4 replies, posted
I'd like to know the difference between using Player:GetAimVector( ) and Player:GetShootPos( ) when used as the start element in TraceData parameter. To where each one points to?
[URL="http://wiki.garrysmod.com/page/Player/GetAimVector"]Player:GetAimVector()[/URL] returns the direction that the player is aiming. [URL="http://wiki.garrysmod.com/page/Player/GetShootPos"]Player:GetShootPos()[/URL] returns the position of where the player will going to shoot from; aiming from.
So, about the Player:GetAimVector(), it means that if the player is aiming into another player, the returned Vector is will be almost equivalent to the position of the other player? [QUOTE=brandonj4;43598454][URL="http://wiki.garrysmod.com/page/Player/GetAimVector"]Player:GetAimVector()[/URL] returns the direction that the player is aiming. [URL="http://wiki.garrysmod.com/page/Player/GetShootPos"]Player:GetShootPos()[/URL] returns the position of where the player will going to shoot from; aiming from.[/QUOTE]
[QUOTE=Zignd;43598571]So, about the Player:GetAimVector(), it means that if the player is aiming into another player, the returned Vector is will be almost equivalent to the position of the other player?[/QUOTE] No. GetAimVector is the direction that the player is looking. [code] ] lua_run print(Entity(1):GetAimVector()) print(Entity(1):EyeAngles():Forward()) > print(Entity(1):GetAimVector()) print(Entity(1):EyeAngles():Forward())... 0.981818 -0.049245 -0.183325 0.981818 -0.049245 -0.183325 [/code]
Note that it's a normalized vector, meaning that its length will always be 1. So if you want to make a trace that originates from the player and goes 1000 units forward, you'd use pl:GetShootPos() as the starting position, and pl:GetShootPos() + 1000 * pl:GetAimVector() for the ending position.
Sorry, you need to Log In to post a reply to this thread.