Hache Posted January 16, 2018 Share Posted January 16, 2018 Hey! This is my first thread, I'm new here, so hello everyone! I started last week with phaser, and I am trying to test some features like extend the world, adding other sprites to background, adding a camera, all of this in the "game" that you make in this tutorial. So now, I want to learn how friction works in platforms or ground. game.physics.startSystem(Phaser.Physics.ARCADE); platforms = game.add.group(); platforms.enableBody = true; var ground = platforms.create(0, game.world.height - 64, 'ground'); ground.scale.setTo(4, 2); ground.body.immovable = true; ground.body.friction.x = 0; I want to set my ground like ice and that the player can slide, but it didn't work and I don't know why. If there is no other code that involves "ground", maybe the problem is with the player sprite? :S The version of phaser i am using is 2.9.4 btw. Link to comment Share on other sites More sharing options...
Hache Posted February 2, 2018 Author Share Posted February 2, 2018 Well, I think I was misunderstanding how friction works. In this thread, Samme said that friction is how much of one object's movement is transmitted to a second object that's riding it, but i didn't understand until I saw an example myself. So this is what I did: Didn't set to 0 the player velocity.x when the left or right key is up, but set a negative acceleration until the velocity.x is equal or less than 0, and then, set velocity.x and acceleration.x both to 0. That gives the player the feeling of sliding through the ice, which is just what I wanted. Maybe there is a better way to do it, but I don't know it xD Link to comment Share on other sites More sharing options...
mickeyren Posted February 2, 2018 Share Posted February 2, 2018 you can try using the drag property - it will slow down your objects to a halt eventually. Link to comment Share on other sites More sharing options...
Recommended Posts