9
\$\begingroup\$

I'm making a PC Horror game in Unity, and I want to have a camera recording simulation in-game - so you can leave a creepy location anytime, and you will have a tape with what you recorded on camera while exploring.

Technically, I need to attach a second camera (hand-cam) to the character's hand, and let the player look through the viewfinder by pushing a button. But in any position, the hand-cam must record everything that is in its focus at that point - floor, stairs, rubbish, etc, whether it's lowered at hand level or raised to match the player's viewpoint.

When the game ends (player leaves or dies), I'd like to have an option to save recorded tapes to a video file (if this is not possible, then to some save file).

How can I implement such a feature in my game? Are there some special Unity tricks, or add-ons and additional modules? Saving decorations and scenes with active triggers, or just grabbing video from screen?

Below is a quick MSPaint concept of what I mean:

concept

\$\endgroup\$
  • \$\begingroup\$ If your game is deterministic (or close enough), another approach would be to just save stuff like positions and animation data, sound triggers, player input and whatever else is relevant and then recreate the scene from this data at a later point. This uses far less disk space than recording every frame to disk, and probably uses up a tad less performance(?). \$\endgroup\$ – Christian Jun 6 '17 at 14:06
6
\$\begingroup\$

You need to render your scene twice.

First, you render the scene from the view of the camera to texture.

Then you render the scene from the players point of view, but with the texture applied to the cameras screen.

What changes between the two render passes is the camera transform used, while the camcorder uses the orientation & location of the camera, the players view uses the orientation & location of the players head. If you're using skeletal animation, this would be as easy as attaching the camera model to the player models hand.

Since you already render to texture then, saving a video would be as easy as saving the texture each frame. When the user chooses to save the video, you could convert this sequence of images to a video format.

\$\endgroup\$
  • 1
    \$\begingroup\$ Be aware though that, if I'm not missing anything, this method would not record any audio at all. From the question I'm not sure if that is relevant or not. \$\endgroup\$ – Christian Jun 6 '17 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.