Aligning static body and regular body Speeds in Infinite Runner

Hi everyone, I’m working on an infinite runner where the player should be able to jump on boxes that move from right to left on the screen.

The issue I’m facing is that I have coins using a regular body that moves right to left too via the setVelocity method.

On the other hand, the boxes use a static body. Everything works as expected except for the fact that the boxes and coins move at different speeds. This is because I move the boxes by manually adjusting the X position of the static body, while the coins are moved using the setVelocity method.

How would you suggest I ensure that both the boxes and coins scroll at the same speed?

Thanks in advance :blush:

Hi, instead of this, I would use regular (dynamic) bodies for the boxes and move them with velocity. You can still set body.immovable = true to make them unmovable for collisions.

Thank you, @samme, it’s definitely working better now.

I stilled needed to put the friction to 0 on the body’s box.

I don’t know if it’s the proper way but it worked :grinning: