Garry's Mod Wiki

CUserCmd:SetViewAngles

CUserCmd:SetViewAngles( Angle viewAngle )

Description

Sets the direction the client wants to move in.

The pitch (vertical) angle should be clamped to +/- 89° to prevent the player's view from glitching.

Arguments

1 Angle viewAngle
New view angles.

Example

Locks the player's view to only vertical movement.

hook.Add("InputMouseApply", "LockToPitchOnly", function( ccmd, x, y, angle ) -- By leaving angle.roll and angle.yaw alone, we effectively lock them angle.pitch = math.Clamp( angle.pitch + y / 50, -89, 89 ) ccmd:SetViewAngles( angle ) return true end)

Page Links


Special Pages


Wikis

?

Render Time: 36ms

Session 0
DB GetPage 2
Generate Html 2
SaveChanges 18
Render Body 0
Render Sidebar 11