Garry's Mod Wiki

Revision Difference

Player:SetEyeAngles#549113

<function name="SetEyeAngles" parent="Player" type="classfunc"> <description>Sets the local angle of the player's view (may rotate body too if angular difference is large)</description> <realm>Shared</realm> <args> <arg name="angle" type="Angle">Angle to set the view to</arg> </args> </function> <example> <description>Points a player at Vector( 0, 0, 0 )</description> <code> local localplayer = LocalPlayer() // Or any player local lplayer = LocalPlayer() // Or any player local vec1 = Vector( 0, 0, 0 ) -- Where we're looking at local vec2 = localplayer :GetShootPos() -- The player's eye pos localplayer:SetEyeAngles( ( vec1 - vec2 ):Angle() ) -- Sets to the angle between the two vectors local vec2 = lplayer:GetShootPos() -- The player's eye pos lplayer:SetEyeAngles( ( vec1 - vec2 ):Angle() ) -- Sets to the angle between the two vectors </code> <output>Local player will look at 0,0,0</output> </example>