Easing camera tracking the player makes followed sprite "jiggle"

I am using go.animate() to lock my camera’s position to the position of my player object … using EASING_OUTQUINT. It works perfectly except for one thing — the slower/finer the camera moves, the more my player sprite “jiggles” relative to the tilemap and other sprites … in this GIF you can see this happening, but it doesn’t appear to happen to the robot sprite.

I’ve tried math.floor, assuming it was a round-off error, but that does nothing. If the camera is still this doesn’t happen. I think this would go away if I pixel snapped, but I’d prefer to have fat pixels that move smoothly.

Just as a matter of interest: I did have this same issue with Unity (only much, much worse), which I never got around to addressing — so I’m assuming it has something to do with a 3D camera pointed at a 2D scene?

I just have the following in fixed_update() for the camera’s GO (target_pos is the player GO’s position):

go.animate(".","position.x",go.PLAYBACK_ONCE_FORWARD,self.target_pos.x,go.EASING_OUTQUINT,1,0)
go.animate(".","position.y",go.PLAYBACK_ONCE_FORWARD,self.target_pos.y,go.EASING_OUTQUINT,1,0)

That is pretty much all I’m doing to track the player!

Here’s a gif of the jigglies:

jigglies

Thanks!

Is the camera orthographic?

Does the same issue appear also with different easing or only with EASING_OUTQINT?

What if you animated that vector in the same call to go.animate?

go.animate(".","position",go.PLAYBACK_ONCE_FORWARD,self.target_pos,go.EASING_OUTQUINT,1,0)

Assuming self.target_pos is a vector3.

Edit: this example code shows this more clearly than I explained it. You can animate the individual components, but you can do the entire vector as is shown here:

Orthographic camera: check!

I tried other easing methods (including linear) and they all caused the jiggle. If I change the update in the camera script to just set the camera to my player’s position the jiggle goes away.

It looks like a round-off error, but rounding everything doesn’t help. I could probably just change my camera movement to “manual” updates of the camera position, I’m just kinda enamored with go.animate() right now and I’m trying to use it for everything. :slight_smile:

Thanks for your help! I’ll post back if I get this figured out.

Good thought! I should be doing that anyway. I will give it a shot , thanks!

Maybe the rounding error is being caused by the interpolation of the two vector components being done at slightly different delta-times since they are two separate animate threads. I don’t know enough about the internals of the engine to say if that is the cause.

edit: clarity

It is strange that there is a rounding error, in my opinion. I would bet that it is a problem of one-frame delay in the update of the camera… but it is just a blind idea…

Perhaps also do it in update() call instead of fixed_update(), since the y component isn’t being used in that example. I guess that’s not what you meant by “rounding error” now that I look closer at the gif.

Also, I’m not sure about starting an animation in either of the update functions. Maybe follow the player, and start the animation when the player stops and the camera has to slow down. Detect this condition, and then start the animation.

If I understand go.animate correctly, it starts a thread with its own update that is called each frame and does the interpolation for you. Right now, you’re canceling the playing animation every update call and it doesn’t ever complete the duration of one second. It appears to work because when the player stops moving, the distance becomes less and less. Causing the jitter.

1 Like

It does not start a thread. The animation is updated on the main thread each update together with all the other component updates.

1 Like

Thanks everybody for your suggestions … all great ones, I tried them all! To no avail, unfortunately … then, by chance, I took a look in game.project … Under “Sprite” I de-selected Subpixels …

And voila!

no_jiggles

Thanks again to everyone for all your help!

7 Likes