Skip to content

Commit

Permalink
Fix bug where _play() can be called twice for a single body
Browse files Browse the repository at this point in the history
  • Loading branch information
diarmidmackenzie committed Jan 5, 2023
1 parent daf2633 commit 6ac5591
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dist/aframe-physics-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -16863,7 +16863,8 @@ var Body = {
if (this.shouldUpdateBody) {
this.isLoaded = true;

this._play();
this._pause()
this._play()

this.el.emit('body-loaded', {body: this.el.body});
this.shouldUpdateBody = false;
Expand Down
2 changes: 1 addition & 1 deletion dist/aframe-physics-system.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/components/body/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ var Body = {
if (this.shouldUpdateBody) {
this.isLoaded = true;

this._play();
// pause / play will result in the object being re-added to the
// physics system with the updated body / shape data.
// pause before playing to avoid addting the body to the system twice.
this._pause()
this._play()

this.el.emit('body-loaded', {body: this.el.body});
this.shouldUpdateBody = false;
Expand Down

0 comments on commit 6ac5591

Please sign in to comment.