Adding lag to my CameraManager

As part of my mission to make my game as modular as possible I am using the CameraManager to manage my camera. I am manually setting the location with some calculations to give distance and also zoom out a little as I speed up.

I WAS using a camera as a component on my pawn and using a spring arm, and one thing I LOVED was the lag option given with the spring arm. Not only did I like the overall effect, but playing around without it I can see it also smoothes over jarring movements, say when my pawn crashes into a wall, the cameras movement follows the pawn exactly so the movement isn’t smooth.

I don’t know how to work it out? I tried lerping with a constant alpha of 0.5 between current position and last position (in theory that would work) but my delta isn’t long enough because last frame the camera was basically the same place as it is now. I wish I could do this but go back 10 frames or something. I don’t know how to do that

don’t know if this might help.

I had a look at that. That one requires that you make a camera actor, and not using the camera manager unfortunately.

So far I have a partial solution but I might be able to get it to work

Basically I grab the players location every X seconds, add it to an array (overwriting the oldest entry with a cycling index system) and grabbing the average value of all elements, to get essentially the average player location over the last X time and use that! Need to fiddle with variables

Actually you can use the same logic as in the video for your playercameramanager. At some point in your PCM you will have to calculate the new position of the camera according to the pawns controller. At that point you have the new location and the old camera location available and can just lerp between them.

I will be at my UE4 PC in the evening, i can then make a small screenshot for you for how i did it.

To do some advertising too, my camera system in my “Advanced Top-Down Template” which will be on the marketplace soon has all that in it already :wink: