• Content Count

  • Joined

  • Last visited

About Razvan-Stafan

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello, I have some questions about the physics engine MatterJs. I try to drag&drop an element but I have problem with the collissions between its and the world bounds or the other objects present in the world. This is my my code: preload(): void { this.load.image('background', '../../assets/grid.png'); this.load.image('avatar', '../../assets/avatar.jpg'); this.load.image('bubbles', '../../assets/avatar1.jpg'); } create(): void { this.matter.world.setBounds(200, 200, 10000, 10000); this.tile = this.add.tileSprite(0, 0, 10000, 10000, 'background').setOrigin(0, 0); this.cameras.main.setBounds(0, 0, 10000, 10000); //The item that I want to drag let canDrag = this.matter.world.nextGroup(false); this.image = this.matter.add.image(400, 200, 'avatar', null, { shape: { type: 'circle', radius: 60 } }).setCollisionGroup(canDrag); this.image.setInteractive({ draggable: true }); this.image.setFixedRotation(); let noDrag = this.matter.world.nextGroup(true); //The item that is fix in the world. this.bubbles = this.matter.add.image(500, 500, 'bubbles', null, { shape: 'circle', ignorePointer: true }).setCollisionGroup(canDrag); this.bubbles.setFixedRotation(); //I use this constraint to have a little bounce when the collision appeared this.matter.add.worldConstraint(this.bubbles, 1, 0.2, { pointA: { x: this.bubbles.x, y: this.bubbles.y } }); this.matter.add.mouseSpring({ length: 1, stiffness: 0, collisionFilter: { group: canDrag } }); } My questions: When I drag the item close to the world bounds there are moments that the collision is ignored so my item disappear from the world. When my item collides with the elements present a force is applied and push my item in the other direction Do you have some solutions for my issues ?