Sprite is shaking when follow another sprite

Hi, I’m trying to create a mechanic for a player to take the item in hands and move it but every time when I do the item is shaking while the player is moving.

This is how I’m doing it:
I have a player sprite, and an item sprite, the player comes near the item and takes it, then I create that item sprite following the player sprite coordinates for example:
potion.x = player.x;
potion.y = player.y;

I tried to update item position in update event, postupdate, preupdate, i tried to add fixedStep: false in arcade psychic and even to follow sprite body, different sprite size, I tried also to update item position with velocity, I tried to move it also at the same time with keys as a player, but it is the same.

Item sprite is shaking always when the player moves and I try to apply the same coordinates as the player sprite.

What I’m considering to try is to use render texture, to take player sprite sheet and add item on each frame, merge it and use it like that, when player drop item i just remove it from render texture.

setting the position of the sprite in the update function should work. My guess is that you have something else moving it at the same time, like a tween.
If not, try updating the position in: this.physics.world.on("worldstep", (t, d) => { })

1 Like

worldstep didnt help but thank you.

I tried samme solution but in this case I used Phaser.Display.Align.In.Center and it was working like charm.

thank you very much

Update: Actually when I did some tests this didn’t solve the problem when the sprite is smaller and the same in size, for example, 20x20 is working fine but if the size is, for example, 20x10 then it is shaking again. I also notice if I change the player speed (velocity number) it will affect that shaking, different player speeds (velocity) will affect shaking depending on the velocity number. Weird I’m basically using a very simple example to test this and it is the same.

In meantime, I meet other devs that had the same problem in phaser and didn’t manage to solve it also no matter what they did.

Since my player sprite is canvas render texture, it is not a problem at all to update the texture and draw object to it, and redraw it again when item is off.