physics-matter

Implements Matter.js rigid-body physics in Phaser 4 games including constraints, sensors, and collision filtering.

Updated May 7, 2021
One-click install
npx skills add https://github.com/travispwingo/travispwingo.github.io --skill physics-matter-travispwingo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: physics-matter
Source: https://github.com/travispwingo/travispwingo.github.io/tree/main/mario/docs/skills/physics-matter
Command: npx skills add https://github.com/travispwingo/travispwingo.github.io --skill physics-matter-travispwingo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up full rigid-body physics in Phaser 4 games requires coordinating Matter.js bodies, constraints, collision filters, and world configuration, which is error-prone without a structured reference. ## Core Features & Use Cases - Body and Game Object Creation: Create Matter sprites, images, rectangles, circles, polygons, vertex-based shapes, and compound bodies with configurable friction, restitution, mass, and sensors. - Constraints and Composites: Build joints, springs, world constraints, stacks, chains, soft bodies, cars, and Newton's cradles, plus pointer-based mouse dragging. - Collision Control and Events: Configure collision categories, groups, and masks, handle collisionstart/collisionend events, and integrate tilemap layers as static physics bodies. - Use Case: Build a platformer where the player is a Matter sprite with custom friction, enemies use collision categories so bullets skip the player, and the tilemap level is converted into static physics bodies. ## Quick Start Ask the AI to set up a Phaser 4 scene with Matter.js physics containing a draggable player sprite, static ground bounds, and collision events between the player and enemy bodies.

Frequently Asked Questions about physics-matter

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Matter.js physics in a Phaser 4 game?▼

Enable Matter physics by setting physics.default to 'matter' in the game config with a matter options object for gravity, bounds, and debug. Then create bodies in your scene using this.matter.add.sprite, image, rectangle, or other factory methods.

How do I create constraints and joints in Matter.js with Phaser?▼

Use this.matter.add.constraint(bodyA, bodyB, length, stiffness, options) to create rigid joints, springs, or pin joints. For pinning a body to a world point, use this.matter.add.worldConstraint with a pointA position.

Matter.js vs Arcade Physics in Phaser, which should I use?▼

Matter.js provides full rigid-body simulation with rotation, constraints, compound bodies, and collision filtering, suited for realistic physics. Arcade Physics is lighter and simpler, better for basic platformers and AABB collision without rotation.

How does collision filtering work in Matter.js?▼

Matter.js uses bitmask categories and masks: setCollisionCategory assigns a body to a group, and setCollidesWith defines which categories it collides with. Collision groups override this: same negative group never collides, same positive always collides.

Why is my Matter.js body not colliding with the tilemap?▼

Tilemap collision requires calling setCollisionByProperty or an equivalent method on the layer before running this.matter.world.convertTilemapLayer. Without setting collision first, no MatterTileBody objects are created for the tiles.

Why do my Matter.js forces seem to have no effect?▼

Matter.js force values are very small, typically between 0.01 and 0.1, while velocity values range from 1 to 15. Forces are not pixel-based, so scale your values accordingly or use setVelocity for direct movement control.