Jump to content

Arcade physics friction??


Legomite
 Share

Recommended Posts

How do you make friction in Arcade Physics? I tried using:

sprite.body.friction = new Phaser.Point(100, 100);

and also tried doing:

sprite.body.friction.y = 10000000;
sprite.body.friction.x = 10000000;

but nothing seems to work... I applied this to the platform the player is standing on. The player moves by setting the velocity to 300. Once I stop the controls, it seems to slide forever until it eventually falls out of the world....

Link to comment
Share on other sites

You're heading in the right direction. But, it seems like friction is only in the box2d plugin. You have several options.

- You could set the velocity to zero when the controls aren't activated. 

- You could decelerate the player when the controls aren't active.

- You could roll your own friction code. This would require some understanding of physics.

- You could purchase the box2d plugin.

Personally, I'd go with the second option of decelerating the player. It's simple and effective for simulating the presence of friction. You could determine the player's direction and set the acceleration in the opposite direction.

Link to comment
Share on other sites

3 hours ago, samme said:

In Arcade Physics friction is how much (in range [0, 0] to [1, 1]) of a platform's velocity is transferred to an object riding it.

You can use drag on the player to slow it down.

Oh, cool! I didn't know that. Might refactor some code to use drag rather than manually setting the acceleration.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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