Hello again, I still want to use matterJS for a 2D game with a LOT of blocks.
Right now to add 50000 parts to an object, It takes nearly 40 seconds, is there anything it can do to boost the performances or should I consider using something else for my game haha !
I would have loved having a realistic physics engine in the game, but maybe it's too slow... :'(
I'd challenge _any_ JavaScript physics engine to cope with 50,000 bodies!
Aside from that being a huge amount of parts (so expect it to be slow), is the only issue when you initially add them? Does it run fine afterwards? Are you using polydecomp?
alright I think I just took a wrong approach to my game. I did not think that one body made of 50000 sub-bodies would hit the performance, but now that I think about it it's completely stupid.. I'm going to rethink my logic and try to picture my static floor as one polygon
Alright. I tried creating one object from vectors for the ground. But as I'm doing a 2D tile based game, I'd need to have holes inside the ground such as caverns. After trying tons of orders for my vectors, I finally found something that, when I render does what I want, however, collisions son't work with this object.
I'm creating my object using :
const obj = Bodies.fromVertices(0, 0, [[
{ x: 0, y: 0 }, { x: 0, y: 400 },
{ x: 0, y: 400 }, { x: 400, y: 400 },
{ x: 400, y: 400 }, { x: 400, y: 0 },
{ x: 400, y: 0 }, { x: 0, y: 0 },
{ x: 0, y: 0 }, { x: 100, y: 100 },
{ x: 100, y: 100 }, { x: 300, y: 100 },
{ x: 300, y: 100 }, { x: 300, y: 300 },
{ x: 300, y: 300 }, { x: 100, y: 300 },
{ x: 100, y: 300 }, { x: 100, y: 100 },
{ x: 100, y: 100 }, { x: 0, y: 0 },
]], {
isStatic: true,
});
It does create a square hole inside of a square but if I add a circle inside the hole it will just go through.. And if I drop this big block on a ground it does not collide either...
Any idea @liabru ?
Most helpful comment
I'd challenge _any_ JavaScript physics engine to cope with 50,000 bodies!