Jump to content

Arcade physics friction??


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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