Problem with Matter Plugin

I am getting an error message with the Phaser Matter Collision Plugin. It’s been a while since I did anything with Phaser, and when I went to work on my old games, nothing is working.

I am using jsdelivr to get Phaser 3 and the plugin. My html head looks like this:

<script src="//cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.js"></script>

<script src="//cdn.jsdelivr.net/npm/phaser-matter-collision-plugin"></script>

In my js file, I have exactly what the website says to do:

plugins:  {
    scene: [
   {
    plugin: PhaserMatterCollisionPlugin, 
     key: "matterCollision",
     mapping: "matterCollision"
        }
     ] },

I was originally using Phaser v. 3.16.2, but that doesn’t recognize the plugin at all. When I switch to the newer version, I am getting errors:

Invalid Scene Plugin: matterCollision

And:

TypeError: undefined is not an object (evaluating ‘this.matterCollision.addOnCollideStart’)

This is where I’m getting the directions from:

Thank you!

1 Like

Can you do

console.log(PhaserMatterCollisionPlugin);

?

Yes, all I get is:

{
}

I figured it out. I needed PhaserMatterCollisionPlugin.default when using the CDN. It’s always the simplest thing :melting_face:

1 Like

Thank you!