JordanSchuetz Posted April 17, 2017 Share Posted April 17, 2017 Hello, I'm working on a realtime multiplayer game and I'm running into a problem with the physics that I'm unsure how to correct. Basically when one player jumps on top of the other from a high distance, it pushes the other player through the platform and the player gets stuck there. Here is the code for the platforms: PlayState._spawnPlatform = function (platform) { let sprite = this.platforms.create( platform.x, platform.y, platform.image); // physics for platform sprites this.game.physics.enable(sprite); sprite.body.allowGravity = false; sprite.body.immovable = true; this.game.debug.body(sprite); }; And here is the code for the players: PlayState._spawnCharacters = function (data) { this.hero = new Hero(this.game, 10, 10); this.hero.body.bounce.setTo(0, 0); window.globalMyHero = this.hero; window.globalOtherHeros = this.otherHeros = new Map(); this.game.add.existing(this.hero); sendKeyMessage({}); }; And here is the collide function between the platform and all of the global players: this.game.physics.arcade.collide(otherplayer, this.platforms, null, null, this); Does anyone have any recommendations on how I can make the players not get stuck in other physics objects? Thank you for the help. Link to comment Share on other sites More sharing options...
JordanSchuetz Posted April 18, 2017 Author Share Posted April 18, 2017 Hi so I wasn't able to find a great solution, however I came up with a little hack that works okay: var collidePlayer = this.game.physics.arcade.collide(otherplayer, this.hero, null, null, this); if(this.hero.y > 526){ this.hero.position.set(this.hero.x, 525); console.log("set") }else if(otherplayer > 526){ this.otherplayer.position.set(otherplayer.x, 525); console.log("set2") } Link to comment Share on other sites More sharing options...
Recommended Posts