phaserjs / phaserjs/phaser

MatterJS bodies produce incorrect collisions with negative scale

Open
#7,247 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
40.3k
Forks
7.2k
PR merge metrics
No merged PRs in 30d

Description

Version

  • Phaser Version: 3.90
  • Operating system: Windows
  • Browser: Chrome/Firefox

Description

When a MatterJS body has its scale set to -1, the detected collisions have supports that seem to always just clamp directly to the shape's vertices instead of where the collision occurred. This appears to be a bug with MatterJS as a whole, as I was able to reproduce it using exclusively MatterJS, but it appears MatterJS is pretty much unmaintained and Phaser has its own implementation of MatterJS built in anyways so I figured it would be better to open the issue here.

Example Test Code

https://codesandbox.io/p/sandbox/rsy4lz
Click to drop a rectangle on top of the pentagon; red dots will appear at the collision. Click the button at the top to invert the scale X of the pentagon to see the red dots will not appear at the collision anymore.

Additional Information

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the linked CodeSandbox reproduction with Phaser 3.90 and compare collision supports before and after inverting the pentagon's X scale. Trace the MatterJS collision handling involved in the reported case; done means supports remain at the actual collision points with negative scale while the existing positive-scale behavior still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.