Using Matter.js as physics engine #2659
-
I am trying to figure out how I would use the Matter.js physics engine instead of the built in realistic physics engine. The reason being that a big part of a game I would like to make is highly dependent on constraints. If someone could point me in the direction of how this might be possible, if it is possible that would be great. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@justinfernald This should be possible to do! I haven't attempted this yet (I'll have some time later this week), but the approach I'd try is using Excalibur's ECS:
I'll let you know what I come up with this week! I'm excited to try this! |
Beta Was this translation helpful? Give feedback.
@justinfernald This should be possible to do!
I haven't attempted this yet (I'll have some time later this week), but the approach I'd try is using Excalibur's ECS:
Build a custom ECS
System
to host the matter.js code Engine/World and run the simulation. It looks like matter.js supports manually running thesimulation.a. Here is a simple-ish system in the docs https://excaliburjs.com/docs/systems/#implementing-your-own-components--systems
Create new a new ECS component type to wrap the matter.js Body/Constraints. When this new component is added to an Excalibur actor that matches a system's types it notifies the system. This notify mechanism in the new system is where you could wire i…