Sweety
March 2, 2023, 10:05am
1
Hey. I make ground layer like that:
const groundLayer = groundMap.createLayer('ground', ground, 0, this.groundLevel);
this.matter.world.convertTilemapLayer(groundLayer);
But when i try to add collision group to this layer, i got a error. How i can add collision group to tilemap layer?
Thanks
samme
March 4, 2023, 5:17pm
2
What’s the error? And see the tutorial:
Sweety
March 4, 2023, 8:59pm
4
I have read this, but still don’t know answer.
My task is : create balls who collides with ground, but not with each other. Ground is a tilemap layer. So my code is :
const groundLayer = groundMap.createLayer('ground', ground, 0, this.groundLevel);
groundLayer.setCollisionByExclusion(-1, true);
this.matter.world.convertTilemapLayer(groundLayer);
player = this.matter.add.sprite(125, 140, 'player')
player.setCollisionGroup(2)
circle = this.matter.add.sprite(140, 40, 'circle')
.setBody('circle')
circle.setCollisionGroup(2)
circle.setCollidesWith(0)
So i also need add collision group / collision category to tilemap ground, otherwise coins will fall through.
but tilemap doesn’t have method setCollisionGroup/setCollisionCategory.