Moving a camera based on the player velocity?

Hello

Im working on a side scroller camera and i got most of its features working properly however there is one that still eludes me.

So, to give some context by default the camera only follows the player on the X and Y axis the Z is locked until the player touches either the top or bottom “margins” of the camera once the player “touches” these ( his location goes beyond the treshold ) then the scrolling begins, in which the camera interpolates its Z to a centered position based on the player Z location

Here is a pretty crude representation of what i mean ( blue square is the player location on the screen )

However rather than directly scrolling the camera to the player position i only want the camera to be “pushed” upwards or downwards based on the player velocity. This way he is always kept within the camera and no matter how fast or quick he is the camera will always follow him

I sort of got this to work by using the FInterpTo node on the camera Z axis and using the vector length of the player velocity for the interpolation speed, like this
241999-
And this actually works pretty well, the camera follows up the player perfectly based on his speed so no matter how fast he goes up or down the player is always kept within the camera view. However my main issue with this is that if i start moving either left or right it starts " jittering " kinda like if the interpolation had trouble catching up, If i fall completely still there is no jitter at all. i have a video of this behavior

So yeah its " almost " working the only thing that is stopping me is this Jitter issue whatever i try to move either left or right while the interpolation is active, I would absolutely appreciate some help with this :slight_smile:

I ended up fixing my issues by simply calculating my margins with the player Z location on the screen divided by the screen height

I ended up fixing my issues by simply calculating my margins with the player Z location on the screen divided by the screen height