I was using phaser 3 with matter js and physics editor to make a body for my tree. I gave the label in the textbox as tree, and the json confirms it. But using the collisionactive event in matter, the tree has a label of ‘’ , empty. Why so? At the moment I just used the label as empty to check it, but I would like to give it a proper label. Adding tree.body.label ='tree'
yields the same result. Any help is greatly appreciated. Thanks.
Just inspected the json and found that there are 2 label properties:
{
"generator_info": "Shape definitions generated with PhysicsEditor. Visit https://www.codeandweb.com/physicseditor",
"tree": {
"type": "fromPhysicsEditor",
"label": "tree",
"isStatic": true,
"density": 0.1,
"restitution": 0,
"friction": 0.1,
"frictionAir": 0.01,
"frictionStatic": 0.5,
"collisionFilter": {
"group": 0,
"category": 1,
"mask": 255
},
"fixtures": [
{
"label": "",
"isSensor": false,
"vertices": [
[ { "x":124, "y":223 }, { "x":125, "y":148 }, { "x":68, "y":194 }, { "x":68, "y":223 } ],
[ { "x":0, "y":155 }, { "x":4, "y":158 }, { "x":17, "y":166 }, { "x":31, "y":166 }, { "x":4, "y":147 }, { "x":2, "y":147 }, { "x":0, "y":150 } ],
[ { "x":33, "y":170 }, { "x":38, "y":171 }, { "x":68, "y":115 }, { "x":11, "y":116 }, { "x":31, "y":166 } ],
[ { "x":23, "y":96 }, { "x":29, "y":97 }, { "x":24, "y":84 }, { "x":21, "y":86 }, { "x":20, "y":91 } ],
[ { "x":32, "y":109 }, { "x":39, "y":110 }, { "x":43, "y":107 }, { "x":29, "y":97 }, { "x":28, "y":103 } ],
[ { "x":14, "y":170 }, { "x":17, "y":166 }, { "x":4, "y":158 }, { "x":4, "y":166 }, { "x":7, "y":170 } ],
[ { "x":4, "y":147 }, { "x":31, "y":166 }, { "x":11, "y":116 }, { "x":5, "y":123 } ],
[ { "x":168, "y":109 }, { "x":170, "y":103 }, { "x":154, "y":107 }, { "x":161, "y":111 }, { "x":164, "y":111 } ],
[ { "x":187, "y":91 }, { "x":184, "y":88 }, { "x":170, "y":103 }, { "x":174, "y":105 }, { "x":182, "y":105 }, { "x":186, "y":102 }, { "x":188, "y":96 } ],
[ { "x":29, "y":97 }, { "x":43, "y":107 }, { "x":154, "y":107 }, { "x":162, "y":0 }, { "x":48, "y":0 }, { "x":25, "y":19 }, { "x":24, "y":84 } ],
[ { "x":170, "y":103 }, { "x":184, "y":88 }, { "x":183, "y":21 }, { "x":179, "y":11 }, { "x":162, "y":0 }, { "x":154, "y":107 } ],
[ { "x":34, "y":5 }, { "x":28, "y":12 }, { "x":25, "y":19 }, { "x":48, "y":0 } ],
[ { "x":172, "y":4 }, { "x":162, "y":0 }, { "x":179, "y":11 } ],
[ { "x":68, "y":194 }, { "x":125, "y":148 }, { "x":68, "y":115 }, { "x":38, "y":190 }, { "x":40, "y":193 } ],
[ { "x":154, "y":107 }, { "x":68, "y":107 }, { "x":68, "y":115 }, { "x":125, "y":148 }, { "x":153, "y":147 }, { "x":155, "y":143 } ],
[ { "x":38, "y":171 }, { "x":38, "y":190 }, { "x":68, "y":115 } ]
]
}
]
}
}
After making the second label(the one in the fixtures array) to tree, it worked!