New camera system | Prevent camera from jumping with character

TLDR: How do I prevent the camera from jumping when the character jumps?

Hi there,

I am creating a different camera system since the default third person camera doesnt fit what I’m working on.
Currently, I am trying to prevent the camera from jumping with the character whenever the character jumps. This is default behaviour of the third person camera.

What I did:
I created 2 scene components inside my Character blueprint.

  1. CameraLookTarget
  2. CameraAnchor

CameraTarget is set on a fixed height above the last touched floor by the character.
CameraAnchor follows CameraTarget.

The CameraBoom/SpringArm is attached to CameraAnchor.

CameraLookTarget keeps following the characters X and Y value but is on a fixed Z value above the floor until the character touches a different floor/platform at a different height. If that happens, the Z value is calculated so that CameraLookTarget is again at a certain height above the “new current floor”.

This is done so that the camera only jumps with the character if it really has to for example when the character lands on a higher or lower platform.

Code below:

Rest of the function:

And after this function has been called, I set the CameraBoom/SpringArm to this:

This works almost fine but there is one small issue.

The Problem:
When the character jumps, CameraLookTarget goes just a little bit up and moves down when the character falls. Once the character lands, CameraLookTarget jumps back to the actual Z Height which I’ve set before.

The Z Height never changes during the entire process until the character lands on a different floor so I cannot understand why there is a small change in the height of CameraLookTarget when jumping.
This behaviour causes a “snapping” of CameraLookTarget and hence CameraAnchor which results in the camera snapping every time when the character lands on the same floor.

Video below:

The purple sphere is CameraLookTarget. As you can see the height stays the same when the character moves around however when the character jumps, the height goes a bit up and down which results of the camera snapping on landing.

What I have tried so far:
I found out that if I remove the Interp To node for the camera boom, the snapping effect goes away but the slight movement of CameraLookTarget stays. But I need the Interp node to move the camera smoothly from floor to floor.

I also tried printing out the Z values of the CameraLookTargetHeight and its always stays the same. My guess is that in the first Code Block I’ve attached above, in the false-block when I set the CameraLookTarget, something weird happens when setting the world location with “Set World Location”. Maybe rounding errors?

Appreciate any kind of help and ideas

Hey @Ekveel , I could very well be shooting in the dark here but have you tried playing with the camera lag.
Try enabling and disabling it, while also changing lag rate and max lag distance as well.

Thanks for your reply,

Enabling camera lag doesnt solve the main issue of the purple sphere slighty moving up and down.
The purple sphere (CameraLookTarget) is at a fixed offset (Z value) aboive the ground and only follows the character on X and Y.
The SpringArm of the camera is attached to a camera anchor (CameraAnchor) which follows CameraLookTarget. This means the springarm movement is not dependent on the purple sphere but on CameraAnchor.
Enabling lag will only make this effect lag a bit but the slight movement of the purple sphere stays even tho the Z value is fixed.
I tried debugging the engine code and even their it keeps the same Z value when passing it into “Set World Location”

that code is a little convoluted for just preventing the camera from moving when the character jumps.

A simpler way to do it using character blueprint:

(8.5 is the height you want the camera to be relative to the character )

There is probably a better way to do it but this is just what comes easiest (quite similar to your own code i suppose just more to the point)

However in this case you seem to be planning on making a platformer of some kind, maybe you would be better off making the camera a separate actor that chases the character but isn’t attached to it, it’d give you more elaborate control over the camera since it would only do what you explicitly tell it to do.

Figured out an even better way to do it, without using world location.

Functionally it ‘plays’ exactly like the gif in my last post.


But it’s better, because it’s fully dynamic, it assumes you are only changing the location of your camera relative to your character in the blueprint on the Z axis (but if that’s not the case for the relative transform then changing this code to use the whole relative location vector instead of getting only the Z)

The benefits to doing it this way are:

  • Any changes made to the camera boom in the blueprint’s settings are automatically respected (you don’t need to change the code if you decide you wanna move the camera a lil higher or lower relative to the character)
  • Since it uses relative transform there are fewer opportunities for game breaking bugs, especially because when the character lands the relative location is set to it’s original default setting, so whenever your character lands your camera is guaranteed to be set exactly like it’s supposed to be with no way for it to go wrong.

If you would like to add interpolation after the do-once node, I would suggest using a timeline. You want as little code as possible to run on every tick as a general rule, it’s always the first thing to optimize for any game.

Another problem you’re likely to encounter is if you run off a ledge instead of jumping, the height wont’ be saved properly because it assumes that you only need it saved when you jump, to solve that the simplest solution would just be to set gnd height whenever any movement key is pressed and the character is not falling, just to be sure.

Hi @Cestarian , thanks a lot for this.
What I’m wondering is how would you make the transition of the camera boom smooth when landing on a higher/lower ground.
I tried using FInterp To like this

This way I still get the snapping effect as decribed in my original post. Also interpolating this way doesnt seem to produce the result I was expecting.
Is there another way to smoothly transition the camera? Am I misunderstanding the use of the FInterp To function?
Maybe safe the location of the camera in another variable and only interpolate when the Z value changes since last frame?


Like i said i would use a timeline.


In my case i set thet timeline length to 1 instead of the default 5. You will have to tune the interpolation speed and timeline length to get a perfect result, but this approach is far more efficient than relying on event tick for the interpolation.

I encountered the issue in your OP there, so what’s apparently happening is that when the player lands the capsule component for some reason doesn’t exactly match it’s original Z location. I think it’s possible the height of the capsule is being tweaked the second you land because of the crouching animation that happens upon landing (the height is also tweaked like that when you actually crouch) which would have this effect. It could also just be an inaccuracy in the engine.

I solved it by simply adding a tolerance range for how close to the original Z you need to be for the interpolation to take effect.

The tolerance range I used is 0.1 but you could possibly want to set it higher because at this state if the ground is even just a little bit uneven the camera will jump to the new height, a value as high as 10 might be good.

Edit: Also on finterp, it takes two values (current location and target location) and spits out a value somewhere between the current and target location (the higher the interpolation speed the closer to the target location the number will be), for it to work it needs to be executed every frame which can be done via timeline or event tick or maybe even a loop in some cases.

If you removed the ‘do once’ node your interpolation code would work however it would be inefficient because that code would be running every frame even when you don’t need it, which will quickly slow down your game’s performance (especially if you keep adding more things to event tick), hence why I suggest using do-once and timeline instead.

An alternative would be to toggle ticking on and off based on when you need thte camera to be moving but that requires a lot of finesse and potentially a lot of changes to your overall blueprint.