S&box Wiki

Revision Difference

Camera#528836

<cat>Dev.Intro</cat> <title>Camera</title> # What is a Camera The camera controls the position and rotation of the rendered scene. It also controls things like the field of view and whether or not to draw the player model. # Example ``` public class FirstPersonCamera : BaseCamera { public override void Update() { Pos = TargetEntity.EyePos; Rot = TargetEntity.EyeRot; FieldOfView = 80; Viewer = TargetEntity; } } ``` # Viewer If you set Viewer it won't render that entity. In first person modes you should set it to the entity you're inhabiting. In third person you should set it to null. # Setting Setting the Camera is the same as setting a <page>Player Controller</page>. ``` public override void Respawn() { base.Respawn(); Camera = new FirstPersonCamera(); } ``` Like the <page>Player Controller</page>, this property can be changed at any time and is replicated to the client.