zazazayou Posted April 18, 2017 Share Posted April 18, 2017 I m building a little platformer-type game and am having this problem: When the player is moving really fast, (basically when he falls a large distance) he no longer collides with stuff, and falls right through the floor. This problem comes up when I switch from making regular sprites in a group for floors and platforms, to loading in a tilemap from Tiled. I also notice a change, which is my only hint that something is working differently with the physics - the sprite's body.touching property no longer reads, and instead body.blocked now reads. So for example, if I let the player jump only if player.touching.down is true, I have to switch this condition when using the Tiled tilemap to player.blocked.down, because touching becomes always false. I don't really know phaser well enough to know why this is, but I just know its weird. here is how my code was before, when just making a group of sprites for platforms: this.platforms = this.add.group(); this.platforms.enableBody = true; var element; platformData.forEach(function( platform ){ element = this.platforms.create(platform.x, platform.y, 'green'); element.scale.setTo(platform.scaleX, platform.scaleY); }, this); this.platforms.setAll('body.immovable', true); // so they don't fall this.platforms.setAll('body.allowGravity', false); // so they can't be moved by other bodies and here is how it is when I load the map from Tiled: //create a tilemap object this.map = this.add.tilemap('level1'); //join the tile images to the json data this.map.addTilesetImage('tilesheet', 'gameTiles'); //create tile layers this.tileLayer = this.map.createLayer('tileLayer'); //collision layer should be collisionLayer this.map.setCollisionBetween(1, 1, true, 'tileLayer'); //resize the world to fit the layer this.tileLayer.resizeWorld(); And in update(): this.game.physics.arcade.collide(this.player, this.tileLayer); So it's weird, it collides just fine in every case, except when loading stuff from Tiled and moving really fast, and I don't really know why in one case bodies touch and in the other case bodies block, or what the difference really is supposed to mean. Link to comment Share on other sites More sharing options...
MTiger Posted April 18, 2017 Share Posted April 18, 2017 This might be related, came across this yesterday. Basically thicken up the tiles game.physics.arcade.TILE_BIAS Link to comment Share on other sites More sharing options...
zazazayou Posted April 19, 2017 Author Share Posted April 19, 2017 Thanks MTiger, that solution worked, just increasing the tile bias, like this: this.game.physics.arcade.TILE_BIAS *= 2; This article here explained why, in case anyone is interested: http://thoughts.amphibian.com/2016/02/dont-fall-through-tile-bias-in-phaser.htm Link to comment Share on other sites More sharing options...
Recommended Posts