Creating an in-game mirror using a RenderTexture to send Camera output to a Plane
Cameras do not have to output directly to the screen all the time. Different effects can be achieved by having the cameras send their output to a RenderTexture asset file. In the scene, 3D objects can be linked to a RenderTexture asset file, and so the output of a Camera can be directed to 3D objects such as Planes and Cubes.
In this recipe, first, we’ll duplicate the over-the-shoulder Main Camera child of the PlayerArmature
, and send the output of this duplicate Camera (via a RenderTexture asset file) to a Plane on one of the house walls. Then, we’ll add a different Camera facing out from the wall. This is so that our Plane will act just like a mirror, rather than duplicating the over-the-shoulder Main Camera
:
Figure 13.20: A copy of Main Camera rendering to RenderTexture, which is being displayed on a Plane in the scene
Getting ready
This recipe builds on the basic...