You can now do Cameras!
First person camera:
namespace Sandbox
{
public class FirstPersonCamera : BaseCamera
{
public override void Update()
{
var player = Player.Local;
if ( player == null ) return;
Pos = player.EyePos;
Rot = player.EyeRot;
FieldOfView = 80;
Viewer = player;
}
}
}
Third person camera:
namespace Sandbox
{
public class DeathCamera : BaseCamera
{
public override void Update()
{
var player = Player.Local;
if ( player == null ) return;
var rot = player.EyeRot;
Pos = player.EyePos;
Rot = player.EyeRot;
Pos += rot.Forward * -130;
FieldOfView = 70;
Viewer = null;
}
}
}
that’s pretty cool actually!
what would Viewer = null be doing? Does it just stop the camera from being seen? If so, would that mean that the DeathCamera only gets viewed for 1 frame?
Viewer sets the entity you don’t want to be rendered. So for example in first person you would set the Viewer to the player model. Death camera doesn’t have a player model so Viewer can be set to null.
I wonder if there’s a more descriptive name we could use. FirstPersonEntity etc
Viewer kind of gives the impression that it’s referring to the player that’s currently looking through the camera so yeah it’s probably worth changing
It doesn’t have to be particularly wordy though, something basic like OriginEntity or hell even just Entity could work as long asit’s properly documented on the wiki
The standard from the SDK would be ViewEnt when you’re spectating so I don’t know if you’d want to carry that convention over
I don’t think OriginEntity
or ViewEntity
convey that the only thing it’s going to do is prevent rendering that entity.
I guess in reality it’s not going to just turn rendering off for the entity. It’ll also enable viewmodels and change where particle effects like tracers come from.
I see, I think OriginEntity would be best for that case scenario then, as that’d probably convey the tracers and particle effects better
This is great! can’t wait to start fiddling with this.
CameraEntity
perhaps?