Skip to content

Removing entities when using matterjs #2809

Answered by eonarheim
Demitor asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Demitor, great question!

The components have deferred removal, they won't be cleared until the end of the frame by default. The force parameter forces immediate removal 👍 The reason is sometimes immediate removal can cause some bugs across system lists

In order for the removal to have an effect on the matterjs world, you'll need to wire the MatterJsSystem to listen for component removals and clean up the Matter.js world. I didn't do the cleanup in the sample originally unfortunately. BUT I've updated the sample but the gist is in the system we listen for the components removal and cleanup.

Here is the sample! Press the "D" key to remove the constraint https://github.com/excaliburjs/sa…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@eonarheim
Comment options

@Demitor
Comment options

Answer selected by Demitor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants