Hagop Posted January 30, 2017 Share Posted January 30, 2017 Hi all I am using Cannon engine and applying physics to a mesh using either of the commands. currentMesh.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, { mass: 8 }); currentMesh.physicsImpostor = new BABYLON.PhysicsImpostor(currentMesh, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 8, restitution: 0.9 }, scene); The mesh drops and restitues successfulyy on another mesh which has Plane impostor and mass = 0. After dropping I want to remove the impostor of the dropped mesh so that the mesh behaves like a "normal" mesh. The reason for doing that is that I want to parent the mesh to the free camera of the scene, because I want the mesh to rotate smoothly with the camera. I could not parent the physics mesh to the free camera. Then there is another question. The currentMesh.position returns the coordinates of the it's position before being dropped even if I evaluate it after being dropped. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 2, 2017 Share Posted February 2, 2017 Hi Hagop! Sorry for the slow replies. Have you done any experiments with currentMesh.physicsImpostor = BABYLON.PhysicsEngine.NoImpostor() ? How about... delete currentMesh.physicsImpostor ? I think that will work. Here's a PG with various experiments... tested at 5 seconds and 10 seconds after drop. http://playground.babylonjs.com/#1VNAYW#77 I really wanted to see sphere.position === camera.position after the parenting, but I couldn't get that to happen. Sphere parenting to camera IS working, though, as best I can tell. Holler back as wanted/needed, or to teach us things you discover. Thanks! Quote Link to comment Share on other sites More sharing options...
dbawel Posted February 2, 2017 Share Posted February 2, 2017 @Hagop - @Wingnut provided you with the basics of the scene you were looking to create. However, simply as a personal preference, I prefer to use sphere.physicsImpostor.dispose(); and not delete(). http://playground.babylonjs.com/#1VNAYW#80 Either way, I believe you have your answers. DB Quote Link to comment Share on other sites More sharing options...
dbawel Posted February 2, 2017 Share Posted February 2, 2017 @Hagop - And here is an example of setting a different mass and then disposing of the sphere imposter: http://playground.babylonjs.com/#1VNAYW#81 DB Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 2, 2017 Share Posted February 2, 2017 34 minutes ago, dbawel said: Either way, I believe you have your answers. thx db. Too bad he had to wait 3 days. That's just embarrassing. I stop working the dailies for a week, and a 3-day-old 0-reply drops through the grates. How many forum helpers here? 40? Sad. Quote Link to comment Share on other sites More sharing options...
dbawel Posted February 3, 2017 Share Posted February 3, 2017 @Hagop - When I use .position it returns the correct x,y,z position. I wrote these values to the console in the PG script below. And I am as embarrassed as @Wingnut is that you didn't recieve an answer to such a simple question sooner. I was also off the grid for a time. I hope you either figured it out yourself, or will come back for the answers. http://playground.babylonjs.com/#1VNAYW#82 DB Quote Link to comment Share on other sites More sharing options...
dbawel Posted February 3, 2017 Share Posted February 3, 2017 OK - I had the mesh.position returning the correct position for the sphere working in the console, and now it does not. Any one have any thoughts as to why this is inconsistant? DB Quote Link to comment Share on other sites More sharing options...
Hagop Posted February 8, 2017 Author Share Posted February 8, 2017 Thanks for the answers guys. Dispose does the job. @dbawel make sure the console.log(sphere.position); is in the timeout function and the correct position will be returned. dbawel 1 Quote Link to comment Share on other sites More sharing options...
Hagop Posted February 8, 2017 Author Share Posted February 8, 2017 Delete does not seem to work, because if after deleting physics if I parent the mesh to the camera and position it (after parenting the position of the mesh is relative to the camera), mesh makes a small jump. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.