S&box Wiki

Revision Difference

Camera#548437

<cat>Code.Camera</cat> <title>Camera</title> # Introduction You can control the game camera by referencing the global clientside variable `Camera`. It is accessible and changeable anywhere in the game loop clientside. # Example usage It is recommended to put your camera code in an event called every frame such as `[Event.Client.Frame]` or `[Event.Client.PostCamera]` (see [Event System](EventSystem) for more info) - or a method such as `FrameSimulate`: ``` public override void FrameSimulate( Client cl ) { Camera.Rotation = ViewAngles.ToRotation(); Camera.Position = EyePosition; Camera.FieldOfView = Game.UserPreference.FieldOfView; Camera.FirstPersonViewer = this; Camera.ZNear = 1f; Camera.ZFar = 5000.0f; } ``` ⤶ **Note:** `Camera.FirstPersonViewer` will not hide the pawn if `EnableHideInFirstPerson = true` is not set.