Jump to content

Jitter in Sprite Movement


simpleyuji
 Share

Recommended Posts

Sometimes, I see a jittery movement when moving my sprite. Movement is done via setting the position.x, position.y directly, and I've tried disabling/enabling physics on the sprite and they both have the same problem. I also have "game.renderer.renderSession.roundPixels = true;" . To simplify my testcase, I created a script that moves the sprite linearly to the left at using setInterval (moveFunction, 1000/30) at increasing displacement (started with moving it by constant displacement factor of 1 pixel every frame, then 2, 3, 4 and so on. As you can see, the jitter effect increases as the displacement factor increases. 

Why is this happening? And what can I do to fix this? 

(1px per frame) http://www.giphy.com/gifs/l4FGpD2zOOtGXklzy

(3px per frame) http://www.giphy.com/gifs/xUPGcCZS0QiZn7Lp5e

(6px per frame) http://www.giphy.com/gifs/26gR0ZrhVBHBgpvji

(9px per frame ) http://www.giphy.com/gifs/3og0INYFVyL95ozchG 

(15px per frame) http://www.giphy.com/gifs/l0Iy3vQZaaHnADrnq

Link to comment
Share on other sites

So I put it in update() that movement code, and it looks smoother. Consequently, changing my original setInterval fps from 1000/30  to 1000/60 made it looks smoother as well. although, yeah, i agree update() should be the right place to put it in. However, this means I'm not able to replicate my original problem (where the character I move in different directions become jittery at times - back/forth shaking movement of sprite). It's actually a client/server model where client instructs server to move, server sends movement positions to client 20fps, and client interpolates in between. And the jittery/shaking movement (I'm using camera.follow(player) ) becomes more likely on poor network conditions. 

 

I'll try to come up with a runnable example . 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...