While previous examples always used a single camera, apart from the mini-map, you can dynamically change cameras using scripts. You could modify their Depth
parameters, so another camera is drawn above the others, but you could also toggle their state. In a more elaborate setup, you could switch between different cameras, for example from first person to third person perspective or to a dedicated Point-of-View (POV) camera to display a particular viewpoint. It is also a way to toggle between user-driven navigation and a pre-animated camera. The following steps show how to perform this:
Prepare your scene with a few camera objects created and positioned in different places. Ensure that only one camera has an active Audio Listener component, to avoid warnings in the console log.
Create a new C# script and name it
switchCamera
. Add a public variable,cameraList
, to contain a list of available cameras, using anarray
. Anindex
variable is used to keep track of which camera...