Use Triggers to Change the Camera Position in Unity.
Make a level progression by changing the camera position.
Objective: Detect when the player collides with a trigger and change the camera position.
In order to make this functionality we have different triggers and camera angles throughout the level. The triggers are to check a collision with the player and the angles are the positions the camera has to take in each part of the level.
So the functionality is very simple. Just check for a collision with the player and assign the new camera position.
We have to create a new C# script called camera trigger and assign it to each trigger.
We have to declare a transform variable to store the reference to the camera angle (we have to assign the camera angle for each trigger in the inspector).In the code we have to use the function OnTriggerEnter. Then check if the collider tag is equal to the player and in that case assign the new position by using the function SetPostitionAndRotation and pass as a parameter the position and the rotation of the camera angle.
And that’s it!!! We change the position of the camera when the player reaches the trigger.