Second Week
Weekly Overview
This week I start setting up the project in the engine and built my project in Unreal 4.27. The goal of the first two weeks is to build Virtual Cameras moving, aiming functions, and their properties.
I built a VirtualCamera.h and make two different variables, one is the “follow at” target and the other one is the “look at” target. Under the tick function, I check if the target is assigned, and if it is, it will do the math and reset the camera to the correct location.
Math
For the follow function, I store the vector between target and camera at the beginning of the game, add it to the target location and set it to the camera. For the look at function, I saved the forward vector by subtracting the target location from the camera location. Then calculate the right vector by getting a cross product from an up vector and forward vector. And use these two vectors to build a rotator and set it to the camera.
Obstacles
When I tried to test the camera, I met some issues with the unreal default setting. I spent some time trying to figure out how to not use the player’s default camera and not let the game spawn a new camera. The way I solved it right now is via level blueprint. This will be redesigned after I start working at Cinemachine brain.
Result
Users can specify the look at target or the follow at target in the Details, and it will work correspondingly. The way I set up avoid attaching the camera to the player, so user can assign the camera to whichever target they hope.
Aryna Ou