sanojian Posted September 27, 2015 Share Posted September 27, 2015 I can't figure out how to make friction work between a crate that the player can push and the collision layer that is a TileMapLayer. Does anyone know how to do this? Here is what I tried.// in create layerCollision = map.createLayer('collision'); game.physics.enable(layerCollision, Phaser.Physics.ARCADE); layerCollision.body.friction.x = 1; crates = this.game.add.group(); game.map.createFromObjects('objects', 12 , 'crate', 0, true, false, crates); game.physics.enable(crates, Phaser.Physics.ARCADE); crates.enableBody = true; crates.setAll('body.friction.x', 1);// in update game.physics.arcade.collide(crates, layerCollision);The player can push the crate, but it keeps sliding like it is on ice. I want it to stop when the player stops pushing it. Link to comment Share on other sites More sharing options...
drhayes Posted September 28, 2015 Share Posted September 28, 2015 Make sure that your crate has "drag" set on its physics body. Drag subtracts from the velocity when there's no acceleration and is a good simulation of friction. Dower 1 Link to comment Share on other sites More sharing options...
sanojian Posted September 30, 2015 Author Share Posted September 30, 2015 Thanks, setting drag.x=1000 on the crate body solved the problem. I am still not sure why fiction did not work but thanks :-) Tilde 1 Link to comment Share on other sites More sharing options...
Recommended Posts