kass Posted March 18, 2014 Share Posted March 18, 2014 Im using 2.0 arcade physics for a platformer i'm making but my player keeps colliding with invisible overhead tiles , running through tiles ,and sinking into the floor. I've tried changing around numbers in my setCollisionBetween and setCollisionByExclusion but collision detection is all over the place. I never really ran into this problem with the earlier phasers.Its to the point where the game is kinda unplayable. The links below are to hastebin.comHere is my tilemap.json. I only want the player to collide with "ground"And here is my actual game code game.js is there anything i can do to fix this? Link to comment Share on other sites More sharing options...
rich Posted March 19, 2014 Share Posted March 19, 2014 Could you try this against the 2.0.1 build I just posted about please. Would be curious to know if it sorts it, although you may have to tweak the tile specific collision values (like TILE_BIAS, or tilePadding on a body). Link to comment Share on other sites More sharing options...
kass Posted March 19, 2014 Author Share Posted March 19, 2014 im no longer colliding with invisible blocks but im still randomly falling through the floor and running through tiles. Link to comment Share on other sites More sharing options...
natedsaint Posted May 1, 2014 Share Posted May 1, 2014 My team did a game for LD48, and we ran into the same issue with falling through the tiles. We also noted that if you tab out when your character is standing on a collision tile, then tab back in, he falls through them. Here's our working theory: Slowing the character's movement speed down reduced the error rate, and they fell through less often. Anything that caused the framerate to drop also increased the error rate. So, we think that a condition occurs in which the physics operation pulls the character through the collision plane (in this case the edge of the tile), and when the engine detects the overlap it just returns false on collision and they continue to fall through. I haven't been able to deep dive into the code yet, but we think that a potential solution is to check for this state and if the player sprite has moved through the collision tile, the engine should handle it by repulsing them back to the edge. We'll continue to investigate and update you with our progress. Link to comment Share on other sites More sharing options...
wayfinder Posted May 8, 2014 Share Posted May 8, 2014 I can confirm this is happening with 2.0.4 still. natedsaint and kass 2 Link to comment Share on other sites More sharing options...
natedsaint Posted May 9, 2014 Share Posted May 9, 2014 I'm not sure I've solved it for a 100% of the cases, but in my particular case, turning TILE_BIAS up to 40 was the magic number. Here's how we implemented collision: this.game.physics.arcade.TILE_BIAS = 40;this.game.physics.arcade.collide(this.player.sprite, this.ground);In our case, this.ground is defined as a layer from the tilemap before this:map = this.add.tilemap('levelTileMapFromTiled');this.ground = map.createLayer('Ground');map.setCollision([2, 3, 4, 6, 7, 8, 10, 11, 12], true, this.ground);It seems to be doing the trick so far, let me know if this helps! Stucky 1 Link to comment Share on other sites More sharing options...
wayfinder Posted May 9, 2014 Share Posted May 9, 2014 The "magic" value seems to be dependent on content – I found that 27 works for my combination of assets and settings, while at 40 (28 and up, actually) my character is placed on top of ledges he shouldn't be able to reach when he jumps into them from below (the ledges only collide with stuff above them). TILE_BIAS of 2 is pretty hilarious, btw. And a good simulator of what it looks like in Firefox, where the frame rate is lower natedsaint 1 Link to comment Share on other sites More sharing options...
natedsaint Posted May 9, 2014 Share Posted May 9, 2014 My tiles are 32x32 so I think that might be a factor: 39 was too few. The weird thing is I could jack it up to 90 and everything settled but every now and again velocity would make my character slide up walls, which was actually kind of neat. Might be interesting to investigate some of these physics engines in hybrid formats. =DHope it helped! The "magic" value seems to be dependent on content – I found that 27 works for my combination of assets and settings, while at 40 (28 and up, actually) my character is placed on top of ledges he shouldn't be able to reach when he jumps into them from below (the ledges only collide with stuff above them). TILE_BIAS of 2 is pretty hilarious, btw. And a good simulator of what it looks like in Firefox, where the frame rate is lower Link to comment Share on other sites More sharing options...
wayfinder Posted May 9, 2014 Share Posted May 9, 2014 My tiles are 32 by 32 also, and my player character is 24 by 48. But your suggestion definitely helped, so thanks again! natedsaint 1 Link to comment Share on other sites More sharing options...
jdavis Posted August 7, 2014 Share Posted August 7, 2014 I'm not sure I've solved it for a 100% of the cases, but in my particular case, turning TILE_BIAS up to 40 was the magic number. Here's how we implemented collision: this.game.physics.arcade.TILE_BIAS = 40;this.game.physics.arcade.collide(this.player.sprite, this.ground);In our case, this.ground is defined as a layer from the tilemap before this:map = this.add.tilemap('levelTileMapFromTiled');this.ground = map.createLayer('Ground');map.setCollision([2, 3, 4, 6, 7, 8, 10, 11, 12], true, this.ground);It seems to be doing the trick so far, let me know if this helps!Thanks a bunch, this issues was bugging me and this simple fix cured the problem right away. Good work. Link to comment Share on other sites More sharing options...
Nepoxx Posted August 18, 2014 Share Posted August 18, 2014 Sorry for bringing this solved thread up, but could anyone explain the "magic" behind the TILE_BIAS attribute? Is that used as interpolation to compute collisions? Link to comment Share on other sites More sharing options...
radim Posted September 26, 2014 Share Posted September 26, 2014 Sorry for bringing this solved thread up, but could anyone explain the "magic" behind the TILE_BIAS attribute? Is that used as interpolation to compute collisions?Hi, i think its about time dependent game loop. When updating position of game objects, you use something like x+=xVelocity*delta, where delta is time between this and previous update. When delta is too big, game object can go through ground, no colision detected. Big delta time can happened, when you dont have enough cpu power, or low priority of execution your game engine code, because switching tabs of your browser or high load of another programs. Try to underclock your cpu, and allow only 1 core for your browser, and /or stress you cpu by some benchmark program, while testing game, it give you object moving through too, because reasons written above.You can fix it by lower count of tiles(tiles width and height will be bigger, bigger collision area, so lower chance to go through), lowering movement speed of your objects, or set the maximum allowed delta time( delta*velocity of object cant be bigger than size of another coliding object). Another option is loop between current position and position of your object in previous update, but it cost more cpu power.Hope this helps. Link to comment Share on other sites More sharing options...
justGoscha Posted August 15, 2015 Share Posted August 15, 2015 Does anyone know why I can't set game.physics.arcade.TILE_BIAS = 40; in typescript? It always saysProperty 'TILE_BIAS' does not exist on type 'Arcade'.Is it because TILE_BIAS is defined as static? msqar, DavidPesta and samme 1 2 Link to comment Share on other sites More sharing options...
msqar Posted February 10, 2018 Share Posted February 10, 2018 On 8/15/2015 at 7:41 AM, justGoscha said: Does anyone know why I can't set game.physics.arcade.TILE_BIAS = 40; in typescript? It always says Property 'TILE_BIAS' does not exist on type 'Arcade'. Is it because TILE_BIAS is defined as static? Happens the same with me! TILE_BIAS doesn't exist anymore or not accesible publicly through game.physics.arcade. What should we do now? Link to comment Share on other sites More sharing options...
samme Posted February 10, 2018 Share Posted February 10, 2018 It's still there. game.physics.arcade.TILE_BIAS = 32; // etc. Link to comment Share on other sites More sharing options...
msqar Posted February 10, 2018 Share Posted February 10, 2018 1 hour ago, samme said: It's still there. game.physics.arcade.TILE_BIAS = 32; // etc. When compiling my code it throws the same error as the guy above: Property 'TILE_BIAS' does not exist on type 'Arcade'. any Link to comment Share on other sites More sharing options...
samme Posted February 10, 2018 Share Posted February 10, 2018 That's an error in Phaser's TypeScript definitions. Link to comment Share on other sites More sharing options...
samme Posted February 11, 2018 Share Posted February 11, 2018 On 8/15/2015 at 3:41 AM, justGoscha said: Is it because TILE_BIAS is defined as static? That's the problem, thanks. OVERLAP_BIAS as well. Link to comment Share on other sites More sharing options...
Recommended Posts