I am trying to get the camera in my game to move smoothly along a “track” to achieve a cinematic scene. To accomplish this I am using a spline and calling GetTransformAtTime() every Tick then applying the resulting transform to the camera. That’s it.
Now the problem - the resulting movement of the camera is not even nearly as smooth as the spline is looking in the editor, instead it slightly jerks left and right and even seems to get stuck for a few frames here and there.
You had me worried there for a second! However CameraSpline is just a variable of type CameraSplineBP which is an actor with only a spline in it. So, unfortunately not the issue
The shots are getting longer here, but now I’m wondering about ‘twists’ on the spline. I can be pretty difficult to get those buggers to lie right. What with the tangents coming in and out of a curve and whatnot.
If that was the case, then the camera is always going to jump in the same place.
You are not wrong, I found that the spline point in the middle of this curve here caused a twitch as you are saying. I managed to fix it by resizing the tangents. However the major issue is still there, that the camera movement feels jerky. What I mean is that even at a steady 50 FPS it feels like I’m looking at 15 FPS because I can see the environment move in a stuttering fashion when I’m in the curve.
I have a hunch, that it might work better with a timeline. Because then the rate along the curve is constant. The problem with using tick, is you become a victim of changing frame rates, during the movement.
I tried for a few hours more with the spline approach and as I got better with placing the splines I noticed that the stuttering was becoming less of an issue. Also I noticed that I could see stuttering in Unreals own SetViewTargetWithBlend so I am now assuming its an issue with how Unreal presents each frame.
These are some guidelines I made up that anyone can follow to create better camera tracks.
Don’t put a spline point in the middle of curves.
To make a smooth curve, the tangents of the 2 spline points must touch each other.
It’s a good idea to put a straight line after a curve, otherwise future movement angle changes feel unnatural.