casey Posted December 10, 2018 Share Posted December 10, 2018 I have a platform where the platform will start tipping (rotating) when the player jumps on it, tipping the player off. The platform rotates now, but the player's gravity doesn't come into effect when the platform rotates--the player stays standing in the air. I can disable the platform body, and the player will fall through, but I want the player's body to move along the platform (slide off). What am I missing? var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); function preload() { game.load.image('ground', 'platform.png'); game.load.spritesheet('dude', 'dude.png', 32, 48); } var player; var ledge; function create() { game.physics.startSystem(Phaser.Physics.ARCADE); ledge = game.add.sprite(0, 400, 'ground'); player = game.add.sprite(20, 20, 'dude'); game.physics.arcade.enable([ledge, player]); ledge.body.immovable = true; ledge.body.allowGravity = false; player.body.gravity.y = 200; cursors = game.input.keyboard.createCursorKeys(); } function update() { this.physics.arcade.collide(player, ledge); player.body.velocity.x = 0; if (cursors.left.isDown) { player.body.velocity.x = -150; } else cursors.right.isDown) { player.body.velocity.x = 150; } //when player goes half way start sliding if(player.body.x > 200){ ledge.angle += 0.5; //ledge.body.enable = false; } } Link to comment Share on other sites More sharing options...
nrbdch Posted December 16, 2018 Share Posted December 16, 2018 Arcade Physics is a system based on AABB collision detection, every sprite has a rectangular body shape and it's not possible to rotate it. You can observe that with render function below. For more advanced physics like slopes, you could use P2 Physics. function render() { game.debug.body(ledge); } casey 1 Link to comment Share on other sites More sharing options...
casey Posted December 19, 2018 Author Share Posted December 19, 2018 Thanks. I don't want to actually rotate the falling object, only have it slide, but I'll see what I can do with P2. Link to comment Share on other sites More sharing options...
Recommended Posts