Skip to content

Conversation

@tylerfurtwangler
Copy link

Problem

Currently when setParts is run, it sets the position and positionPrev to the new total parts centre values. This is fine when the body is stable/constant when being set, however for actively moving objects this will cause the new body to have no delta between positions.

This factors in when calculating the new velocity during update: https://github.com/tylerfurtwangler/matter-js/blob/master/src/body/Body.js#L638

Fix

This change uses the existing body positionPrev and position values to come up with a delta to apply to the body to keep the previous relative positions the same during a setParts call.

Testing Notes

I am unfamiliar with the process, and can close this PR if more is required for the main repo. This can be seen by calling setParts on a falling object, the object "stalls" midair as it no longer has a positionPrev delta from position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant