Part and Click (part 3)
Now that we have our Nav Mesh baked in and with static objects which the player can sneakily move around, it is time to incorporate the camera and update the transform information when the player passes a certain trigger point on the map. We will need to create a new script which basically contains an holder which we can apply to the preset camera angles in the game.
Camera Trigger Script
Create a brand new script and call it “Camera Trigger”, this script will house the necessary information to pass the preset camera angle data to update the main camera.
The script will be very simple, you will need a public Transform handler which can be named anything. Then we need to have an simple “OnTriggerEnter” event which the collider is checking for a player tag. When the play passes through the trigger, we pass along the new camera position to the main camera. To do this, we will utilize the command called “Camera.main.transform” this will access the main camera and we can update both the position and rotation. Since our Transform data is stored under the handler called “myCamera” we will delegate the new data from there.
Assigning The script and game Object
Save the script and select every camera Trigger object within the Hierarchy and drag and drop the new script as a component. You will noticed that the script has a slot that is asking for a Transform Object. This is where you will be assigning the camera progression Angles.
Finally before we can test out the new feature, we must check the Camera Triggers Box Collider “Is Trigger” as active. Then add an Rigidbody to each camera trigger so the “OnTriggerEnter” command can function properly.