Tenth Week
Project Introduction
This week's first goal is to rebuild the swap function in Cinemachine Brain to solve last week's engine crash problem. And the next goal is to reproduce the Clear Shot Camera.
Swap Function
Last week, I sorted the camera's in the scene with their priority. While I can successfully sort the camera, when I use the camera as the viewport, the engine crashed. To solve this, I change the swap function I wrote, which is to save the first index to a temp object then delete it in the array, and then insert it, into the brand new Swap function. The swap function uses the std::move concept, which moves the first index element to a temp object then move the second one to the first index, then moves the temp object to the second index.
After the refactoring, now I can use the sorted priority camera list without any engine crash problems.
Clear Shot Camera
This camera is interesting, that it has a list of cameras, and all cameras will have the same target. If the current camera couldn't see the target, it will find the one which can see the clear target.
To build this camera, first, I need to figure out how to use Raycast to know if the target is in the camera. I made a DoTrace function that will get the first object the ray trace hit. If it's not the target, then it will change to another camera based on their priority.
The camera also supports different blending modes.
Easy to Use
To let the code easier for the user to use, I made the NextCamera function in the Cinemachine Brain, so the user can arrange their camera's priority in their preferable way, and use the blueprint to call the NextCamera function to change the camera whenever they want.
Obstacle
The Clear shot camera has a user-defined list of the camera. If the user didn't assign the correct format, it may cause the engine to break. To solve this problem, I need to consider all the possible situations which may cause the problem and make an if statement to check the condition.
Though the PPP has reached the end, there are still lots of functions I want to support in my cinemachine. I hope I can keep improving it and make it a really useful tool for Unreal users.
Next Week Plan
The project has reached the end, next week, I'm going to wrap up all the functions of a scene to show how this Cinemachine can be used.
Aryna Ou