Jump to content

Pausing physics (possible bug)


RobS
 Share

Recommended Posts

Hi,

Thought I'd pop this in here as it's my first post but it might require moving to bugs.

I'm trying to toggle physics on and off for certain meshes, I've knocked together this simple demo which basically works:

http://www.babylonjs-playground.com/#YLJVQ#2

On run the 10 planes drop on to the box, bounce around a bit then settle. All good. If you then click the scene it should go in to a physics paused state and the 10 planes reset themselves above the plane. Cannon is throwing an error here and so the 2nd to 10th plane slowly start sinking down. Error stems from line 68.

If I use Oimo then the pause state works well however the unpaused physics motion is a bit mad so I'd prefer to stick with Cannon.

So really, this leaves me with two questions. Is the way I'm changing the physics impostors the best way enable/disable physics? And, is this a bug in CannonJS?

Cheers,

Rob

Link to comment
Share on other sites

I believe I've sorted it:

http://www.babylonjs-playground.com/#YLJVQ#4

if (pl.physicsImpostor){
	scene.getPhysicsEngine().removeImpostor(pl.physicsImpostor);
}

To (surprisingly) remove the imposter rather than this route. 

pl.physicsImpostor = new BABYLON.PhysicsImpostor(pl, BABYLON.PhysicsImpostor.NoImpostor, scene);

No Script errors from Cannon now.

 

Cheers,

Rob

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...