Creating the shooting behavior
Now, with a traditional first person shooter, we shoot a bullet from a gun to damage enemies. However, we will create a camera that will shoot pictures to damage enemies. To show how easy it is to do, let's get started! Perform the following steps:
The first thing we need to do is go to the FlashlightController object we created earlier. So, with it selected, double-click on it to center the camera on it.
Our camera weapon is going to be another object, which will be a child of the Main Camera object. To do this, first select the Main Camera object that is located on our FlashlightController object and then navigate to GameObject | Create Empty Child. Also, in the Inspector section for this newly created object, confirm whether the object's position is
0,0,0. If it isn't, set it. Finally, name the objectPhoto Camera. Have a look at the following screenshot:
Next, add a camera component by clicking on the Add Component button at the bottom of the Inspector tab...