Garry's Mod Wiki

Player:SetEyeAngles

  Player:SetEyeAngles( Angle angle )

Description

Sets the local angle of the player's view (may rotate body too if angular difference is large)

This function works differently when the player is in a vehicle. In that case passing Angle(0, 90, 0) will have the player look forward (out the windshield) and Angle(0, 0, 0) will have them look to the right.

Arguments

1 Angle angle
Angle to set the view to

Example

Points the first player at Vector(0, 0, 0) or forward if they are in a vehicle

local ply = player.GetByID(1) if (not ply:InVehicle()) then local vec1 = Vector( 0, 0, 0 ) -- Where the player should look at local vec2 = ply:GetShootPos() -- The player's eye pos ply:SetEyeAngles( ( vec1 - vec2 ):Angle() ) -- Sets to the angle between the two vectors else ply:SetEyeAngles( Vector( 0, 90, 0 ) ) end
Output: The first player will look at 0, 0, 0 or forward if they are in a vehicle