I’ve decided to write a bit about the scripting in my game.

Today: The camera system.

The cam can be opened with C and views a snapshot of the control’s video feed. It’s not displayed in real-time because that would be too easy since the player could just run around with the cam open all the time.

Camera Scripting

The camera screen is a render texture that displays the image from a separate camera, the control’s cam.

This camera has a bunch of post-processing effects to give it a more “video feed” look. To keep this look and avoid a frame time spike when brining up the camera, it only renders at a pretty low resolution.

The cam itself renders all the time, but it’s always disabled. When the player presses C, it gets activated for just one frame, just enough to give the screen an updated image to display.

The photo system

There is a script attached to the screen which handles taking photos.

If the player opens the camera, a ray detects the object the player was looking at and checks if it has a “PhotoRequired” tag. If it does, it shows a message that it was saved by passing the object’s name to the “infotext” dialogue system.

Internally, the photographed object’s name gets added to a list which can be accessed by other scripts later.