Hello,
I have an issue with my unit gameobjects “jumping” through collision gameobjects (iso tiles) that I have setup with matter physics…
I have included a video showing what this looks like.
My unit is setup like so:
unitSprite = this.scene.matter.add.gameObject(this, { shape: 'circle', circleRadius: 15} );
unitSprite.setCollisionCategory(groundunits);
unitSprite.setCollidesWith([ground, groundunits]);
unitSprite.ignoreGravity = true;
unitSprite.setBounce(0);
unitSprite.displayWidth = 30;
unitSprite.displayHeight = 30;
unitSprite.scale = 0.4;
var circle = new Phaser.Geom.Circle(150, 150, 40);
unitSprite.setInteractive(circle, Phaser.Geom.Circle.Contains);
My groups are like so:
tileGroup = this.add.group();
dontWalk = this.add.group();
ground = this.matter.world.nextCategory();
groundunits = this.matter.world.nextCategory();
tileGroup.setImmovable = true;
dontWalk.setImmovable = true;
And each tile as it is drawn is done so like so:
//THE ISOMETRIC POLY SHAPE
var tile = new Phaser.Geom.Point(i,j);
const tx = (j - i) * tileWidthHalf
const ty = (j + i) * tileHeightHalf
const isotopleftX = centerX + tx + tileWidthHalf; //TOP OF DIAMOND
const isotopleftY = centerY + ty - tileHeight; //TOP OF DIAMOND
const isotoprightX = centerX + tx + tileWidth; //RIGHT OF DIAMOND
const isotoprightY = centerY + ty - tileHeightHalf; //RIGHT OF DIAMOND
const isobottomleftX = centerX + tx; //LEFT OF DIAMOND
const isobottomleftY = centerY + ty - tileHeightHalf; //LEFT OF DIAMOND
const isobottomrightX = centerX + tx + tileWidthHalf; //BOTTOM OF DIAMOND
const isobottomrightY = centerY + ty + 1; //BOTTOM OF DIAMOND
const iso = isotopleftX + ' ' + isotopleftY + ' ' + isotoprightX + ' ' + isotoprightY + ' ' + isobottomrightX + ' ' + isobottomrightY + ' ' + isobottomleftX + ' ' + isobottomleftY;
//WATER (NON-WALKABLE TILE)
if (tileType==0)
{
thisTile = this.matter.add.sprite(centerX + tx, centerY + ty, 'flatsprite', 5, { shape: { type: 'fromVerts', verts: iso, flagInternal: true } }).setStatic(true)
thisTile.depth = centerY + ty;
thisTile.tileX = i;
thisTile.tileY = j;
dontWalk.add(thisTile);
thisTile.setInteractive();
thisTile.setCollisionCategory(ground);
thisTile.setCollidesWith([groundunits]);
thisTile.body.enable = true;
thisTile.body.immovable = true;
}
Am I missing something here? Why is the unit jumping through the tiles?
badcollisions.mkv (1.3 MB)