Jump to content

Object stuck to moving platform


Recommended Posts


I'm making a simple platform game in which the player is always at the center of the world and the objects move towards him from right to left.

When the player is over a moving platform, it sticks to it and they move together. It removes the player from its original position.

I have tried setting the player.body.x to game.world.centerX on update, but it looks clumsy. You can see when the player position is being reseted.

update: function () {

  player.body.x = game.world.centerX;



The documentation shows two body properties that I could use: drag and friction. But I can't get to make any of them work out.

This is the position I want the player (white ball) to stay on:


After the play jumps over a platform and sticks to it:



Does drag/friction work on arcade physics? If so, how could I use it? Should I set one of these properties on the platforms or on the player?

Any help is appreciated! Thanks in advance!

Link to comment
Share on other sites

3 hours ago, Matthew Cooley said:

You could make it so the character is the one that is moving and the camera is locked to it. 

Then set all the environmental objects to be immovable, while applying a steady X velocity to the character on update(), which should prevent any sticking.

It was like that before. The game world was pretty wide and the player was the only moving object.

But the game ran at 30 fps or less on mobile. Making a smaller world improved the performance a lot, but made that problem appear. :/

Link to comment
Share on other sites

1 hour ago, samme said:

I think you want

platform.body.drag.x = 0;


Thanks samme! I forgot about .body. The drag property was already 0, but the friction was set to 1.

platform.body.friction.x = 0;

It is working real smooth now :D


Link to comment
Share on other sites


  • Recently Browsing   0 members

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