Limit Camera Lag to Z-Axis?

Hello all, I feel I’m so close yet so far away on this one. Trying to implement a 3D camera solution where the camera follows the character and the player can control the rotation as in most 3rd person games, but camera lag is limited to only the Z-Axis. I’ve read so many other posts on this, but have not yet been able to implement a perfect solution.

(As shown in images below:)

In my Character BP, on Begin Play, I spawn a new camera at the Spring Arm’s socket transform and then set it as the View Target. Then on Tick, I update the transform of this new camera, blending between its current location and the spring arm’s socket location.

The lag works perfectly smooth in the Z-Axis, however, any other motion of my character (in X and Y) results in terrible vibration, especially when switching directions. Something is clearly not working right with this setup. Hoping someone with more experience than me can spot the obvious problem or perhaps has a better solution for tackling this… thanks so much!

1 Like

Praise God – problem is solved and it was even easier than I thought! Thanks to @Everynone for this fantastic solution as shown HERE.

There’s no need to spawn another camera, simply attach a camera to your spring arm as normal, then set the spring arm to use “Absolute Location”.

EDIT (10-13-2022): While you can technically do this under its “Transform Details” (by clicking the little arrow next to “Location” and choosing “World” for its “Location Type”, this can potentially cause some problems when trying to position your character in the Editor (since the spring arm and camera will stay put while the character is moved around). Also, when playing in a Standalone Game with a landscape, the camera will visually slide up into position, rather than starting where you want it to. To avoid these problems, we will set the Absolute initial location of the Spring Arm on Begin Play.

So from Begin Play, get a reference to the Spring Arm and add a “Set Absolute” node. Tick the box for “New Absolute Location”. Now add a “Set World Location” node. Next add a “Get Actor Location” node, then a “Break Vector” node, and make a Float Variable called “Spring Arm Z-Offset”, which will then be added to the Z value. This variable controls how high the spring arm will stay above the center of your character’s capsule. I used 40 for my character. Plug all this into a Make Vector node and connect to the “New Location” input on the “Set World Location” node as shown below:

Now, create a Custom Event (or Function) called “Camera Lag”, and set it up as shown below. This will smoothly blend between the world location of your spring arm and the Actor Location (your character’s root or capsule). Call this Custom Event on Tick and you will now have smooth camera lag in the Z-Axis only! :smiley:

9 Likes