# Player shakes when riding on a moving platform

**URL:** <https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306>\
**Category:** Phaser 3\
**Created:** [July 31, 2019, 3:33pm UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306 "2019-07-31T15:33:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Caminante](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@Caminante](https://phaser.discourse.group/u/Caminante)\
**Post date:** [July 31, 2019, 3:33pm UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306/1 "2019-07-31T15:33:37Z")

</div>

Hello!

I have a moving platform that consist of a container with background sprite and text. I have to make it move in circles around some point (like here: [http://www.html5gamedevs.com/topic/24435-rotating-a-spritebody-around-the-point-with-keeping-the-orientation/](http://www.html5gamedevs.com/topic/24435-rotating-a-spritebody-around-the-point-with-keeping-the-orientation/)) I have tried different ways of moving (along a Path or setting angular velocity, but in any case when player jumps on it and rides, it starts to shake as though it cannot calculate the player position at once. With PathFollower the effect is not so strong (I am updating player position in the path update loop), it is almost good when riding the left half of the circle and gets much worse on the right half.

Any ideas what can cause that and how can I fix this problem? Thank you all for attention.

---

<div class="post-metadata">

**Author:** ![tony](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@tony](https://phaser.discourse.group/u/tony)\
**Post date:** [August 1, 2019, 7:23am UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306/2 "2019-08-01T07:23:43Z")

</div>

Can you post the code (and format it with the `</>` button) to give us a better idea?

---

<div class="post-metadata">

**Author:** ![Caminante](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@Caminante](https://phaser.discourse.group/u/Caminante)\
**Post date:** [August 1, 2019, 3:45pm UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306/3 "2019-08-01T15:45:50Z")

</div>

@tony thanks for reply, I almost figured it out (one pixel discrepancy was causing the whole system to ruin 🙂), but still have the text jitter problem. It is not just so bad, but I really wish it runs smoothly.

```
this.bg.startFollow({
      from: 0,
      to: 1,
      duration: this.bg.path.getLength()*7,
      yoyo: true
      repeat: -1,
      repeatDelay: repeatDelays[this.movement],
      ease: "Linear",
      onUpdate: () => { 
//some code
       this.adjustTextPosition();
      }
    });
  }

 adjustTextPosition(){
    this.text.setX(this.bg.getCenter().x - this.text.width/2);
    this.text.setY(this.bg.getCenter().y - this.text.height/2);
  }

```

_this.bg_ is the sprite inside container and _this.text_ is the text inside container

---

<div class="post-metadata">

**Author:** ![tony](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@tony](https://phaser.discourse.group/u/tony)\
**Post date:** [August 1, 2019, 5:34pm UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306/4 "2019-08-01T17:34:23Z")

</div>

Total disclaimer - I’m probably just as new to Phaser as you are.

However, I’ve had jitter problems before, and you see that when the text is being updated a little bit after the background has moved.

I’m seeing you update the text position, but where/when does the background get updated?

---

<div class="post-metadata">

**Author:** ![Caminante](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@Caminante](https://phaser.discourse.group/u/Caminante)\
**Post date:** [August 2, 2019, 6:49am UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306/5 "2019-08-02T06:49:46Z")

</div>

That is a good point, but I guess it is not the case - background is the PathFollower itself and I’m updating text position in its onUpdate loop. Probably it gets behind because update happens after the background makes its move.  
What helped you solve your jitter problems?

---

<div class="post-metadata">

**Author:** ![tony](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@tony](https://phaser.discourse.group/u/tony)\
**Post date:** [August 2, 2019, 3:33pm UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306/6 "2019-08-02T15:33:02Z")

</div>

In the past, I remember having a problem where an draggable sprite wasn’t following the mouse. I think the problem in the end was that the position of the image was relying on some variables `myX` and `myY` that only got updated before the mouse had moved. So they coords were always one step behind.

Maybe `onUpdate()` is being called before the background itself changes its position?

---

<div class="post-metadata">

**Author:** ![Caminante](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@Caminante](https://phaser.discourse.group/u/Caminante)\
**Post date:** [August 5, 2019, 7:30am UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306/7 "2019-08-05T07:30:42Z")

</div>

@tony I think you are right. It really looks like just a small single step behind. So does it mean that onUpdate fires before the sprite updates itself? How did you fix your mouse drag problem?

---

<div class="post-metadata">

**Author:** ![tony](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@tony](https://phaser.discourse.group/u/tony)\
**Post date:** [August 6, 2019, 6:30pm UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306/8 "2019-08-06T18:30:12Z")

</div>

Hm, is this Phaser2?

---

<div class="post-metadata">

**Author:** ![Caminante](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@Caminante](https://phaser.discourse.group/u/Caminante)\
**Post date:** [August 7, 2019, 5:16am UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306/9 "2019-08-07T05:16:29Z")

</div>

No, I’m using Phaser 3.

---

<div class="post-metadata">

**Author:** ![jorbascrumps](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jorbascrumps/32/1649_2.png) [@jorbascrumps](https://phaser.discourse.group/u/jorbascrumps)\
**Post date:** [August 7, 2019, 10:00pm UTC](https://phaser.discourse.group/t/player-shakes-when-riding-on-a-moving-platform/3306/10 "2019-08-07T22:00:55Z")

</div>

Sorry to jump in here, but can you share how you’ve attached the player to the platform? Are they able to walk around freely? I happen to also be working on a moving platform and my player is unable to remain on the platform.
