Ralph Posted January 26, 2017 Share Posted January 26, 2017 Hey all, So I recently switched my entire game over to Phaser Isometric by @lewster32 and now I keep running into an issue with collision. With just spawning a sprite in and not chaning any of its body properties, collision happens when the TOP of my player's body box reaches the TOP of the sprite's body box. This is a problem because it allows me to just walk through the sprite diagonally, which is not what I want. In fact, what I want is for collision to happen when the BOTTOM of the body boxes touch. (Sidenote: when I say body box I'm referring to the the 3d body shown through a body debug). Here is an example of how it works with no changes made to the body of either sprite. This is collision happening with no modifications: image - side note I am moving up and to the left in this picture, not down and to the left. This is after some changes to the body, the same thing happens too but it more closely represents what I *want* to happen, except it's still happening only with the top of the player sprite and tree sprite. image 2 Similarly, when I go to the top right side of the tree and move down into it, my body will go through the body box until the top of the body box hits the tree's box. When I mess with the Z values it all breaks and no collision will happen either. On top of that, changing the sprites anchors PAST (.5, .49999) also breaks something. Collision will happen at an anchor of (.5, .4999) but not at (.5, .5), it's very strange. Edit: Also, if i set the anchor to greater than (.5, .5) AFTER I enable isoPhysics on the body, the sprite's position gets moved thousands away and sometimes into the negative's. Here is my code to spawn the sprite and player. There is much more that goes into spawning the sprites, but this is anything that could even be related to the issue at hand. player1 = game.add.isoSprite(1000, 1000, 0, 'person'); game.physics.isoArcade.enable(player1); game.physics.isoArcade.collide(player1, itemGroup, null, null, this); createSprite = game.add.isoSprite(1250, 1250, 0, itemGet(chunks.chunks[i][slot]), null, itemGroup); //the anchor and body.setSize code here draws what you see in image 2. With these lines commented out, it outputs image 1. createSprite.anchor.setTo(.5, .49); game.physics.isoArcade.enable(createSprite); createSprite.body.setSize(40, 40, 0, 27, 27); createSprite.body.immovable = true; Any help is GREATLY appreciated. Ive been trying to fix this for a few days now, nothing I do works. Link to comment Share on other sites More sharing options...
lewster32 Posted February 20, 2017 Share Posted February 20, 2017 There have been some recent PRs to the (now rarely maintained) Github project which may fix this. Unfortunately I haven't created a distributable with these fixes in, but they're there if you want to clone and build, or apply the patches manually. Link to comment Share on other sites More sharing options...
Ralph Posted February 21, 2017 Author Share Posted February 21, 2017 Yeah, a few days after I posted this I fixed the issue by changing all sprites body shape. By shifting the Z offset of each sprite to negative sprite's Z value plus 1, everything was 1 unit off of the "floor" and collided properly then. The issue arises because if you set the z value of a sprite to be 0, it doesnt actually change the height, it just pushes it through the floor it seems. I ran across another issue with anchors, which i also fixed, but that required a source change that I documented on the open issues of the plugin. Overall great plugin, even with the dying support, no worries though, all projects must come to an end sometime. Link to comment Share on other sites More sharing options...
Recommended Posts