Lag in DOM sprite position updates?

Hi Everyone!

I’m using a DOM object in my game as a clickable button that appears above the player character’s head. The button can follow the player around, so I’ve set the position of the button to the player’s position in the scene’s update method.

It works fine, but I’ve noticed there’s a slight lag in the update - the DOM button seems to be a bit behind the player’s position by a few frames.

Screen Recording 2020-10-29 at 10.44.40

Does anyone have any idea why this might be happening?

If you’re using Arcade Physics, you should follow the physics body.

Thanks @samme, That was it!!

For some reason I thought that sprite.x was an alias for sprite.body.position.x. This explains a lot, glad I’ve got that nuance sorted out now :slight_smile: