S&box Wiki

Camera

Camera

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 Player Controller.

public override void Respawn() { base.Respawn(); Camera = new FirstPersonCamera(); }

Like the Player Controller, this property can be changed at any time and is replicated to the client.

Special Pages


Wikis

?

Render Time: 11ms

DB GetPage 1
Generate Html 1
SaveChanges (1) 6
Render Body 0
Render Sidebar 1