Project Alex - Dynamic TPP camera - Resident Evil 4 & The Callisto Protocol inspired


Hi - In the last post I talked about many elements  that make up locomotion and combat in Resident Evil 4 and The Callisto Protocol kind of games, this time I will focus on dynamic changes in third person camera. Besides basic project setup this was the element I worked on.

I managed to achieve:

- Dynamic changes to camera's FoV, Camera Lag and Camera Offset based on a players state.

- Changes can be made a multiple modifiers at once without breaking and overriding values

How did i manage to do it?

Based on article by https://www.unrealengine.com/en-US/tech-blog/six-ingredients-for-a-dynamic-third...  I decided to stick to the rule of only adding values without overriding any. In essence values get changed over time and summed up each frame to a final value that is represented on screen. I probably commited heresy coding this but hey! It works.

Here is the final effect:

Here is a general idea behind the system:


To start I created a few new things:

 FExtendedCameraInfo struct with properties that will be driving changes in camera during runtime.


ExtendedCameraComponent, and ExtendedSpringArmComponent and assigned them to the player:


ExtendedPlayerCameraManager which at the start of the game gathers references to camera and spring arm from player pawn which are later accessed by modifiers through getter functions. 


ExtendedCameraModifier as a base class for all my camera modifiers which has access to ExtendedPlayerCameraManager. Through this access it can also access Camera and SpringArm


Then I stumbled upon a problem when accessing these references to check players Gameplay Tags from camera modifier right after game starts. It turned out that the default modifiers plugged into the array are initialized before CameraManager gets assigned a player controller. To work around this I decided to create a callback that gets fired once references are assigned properly. Each modifier binds itself to OnInitialized callback OnAddedToCamera() and once the references are set a few frames later modifiers get notified through the callback and can access camera and spring arm.

Finally I created ExtendedDynamicCameraModifier to actually modify the camera and spring arm based on GameplayTag present on the player's Ability System Component during the ModifyCamera(). After the camera modifier OnInitialized is called the modifier adds itself to the spring arm's array of modifiers through AddModifier()


SpringArm iterates through every ExtendedDynamicCameraModifier's FExtendedCameraInfo values, summes them up  then adds them to its own default values creating an offset that is changed every frame through each individual modifier. Then it  resets it to 0 again to not accumulate changes just to do it again in the nex t frame.


Notice that the X value of the offset is added to the Target arm length of the spring arm instead of the Socket offset. This is to prevent wall penetration which works wrong when changed through socket offset.

Lastly I created three blueprint assets with varying properties and requirements and added them as default modifiers to camera manager:



Then for debug purposes i made 3 inputs in player blueprint that add and remove required gameplay tags on press/release so once a gameplay tag required by modifiers is added it starts blending in its values to the final effect.

The final effect:


Anyway - thats all for this post, I hope you learned something interesting! :D Im not sure about the format of these posts, itch does not seem to be too friendly with posting code or even s ill fiddle around to make the page look readable.  Thanks for reading, have a good one :D

Leave a comment

Log in with itch.io to leave a comment.