ian Posted March 28, 2016 Share Posted March 28, 2016 I use babylon.2.4.0-alpha with cannon version 0.6.2 (for physics and SphereImpostor I need cannon because it implements mesh impostor. I have ball and set it this values playBall.setPhysicsState( { impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 1, restitution: 0 } ); Can anybody tell me if there are problems with mass and restitution, because if I change value there is no diffrenece ! If I use oimo physics then there is difference if I change mass and restitution, but I need mesh impostor for maze. So I can use oimo. Can anybody thell me if there is bug in cannon for mass and restituion ? Or in cannon.js is not implemented mass and resitution? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 28, 2016 Share Posted March 28, 2016 Hi Ian http://www.babylonjs-playground.com/#BEFOO#4 Looks like backward compat is a little broken. remark-out lines 38-39, then activate lines 35-36... then all is good. hmm. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 28, 2016 Share Posted March 28, 2016 http://www.babylonjs-playground.com/#OJLMR#1 here you go buddy. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 28, 2016 Share Posted March 28, 2016 That's the NEW stuff, P8. Now get back to troubleshooting where the backwards-compat bug is, eh? Hurry up, we haven't got all day! Yes, Ian's ball is bouncing again, but we need to check on Raanan to make sure he doesn't need an ambulance. The first person to discover WHY setPhysicsState version is causing bad sphere bounce... wins 13 cents and my left sock! WOW! Ready? GO! Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 28, 2016 Share Posted March 28, 2016 challenge acceptedhttp://www.babylonjs-playground.com/#OJLMR#2 changing any of the settings has an effect now. this honestly handles the exacts same way and is in fact calling the same method if im not mistaken. you would still access the imposter thorough the object.pBody if you need to change anything or access any imposter local data.http://www.babylonjs-playground.com/#OJLMR#3 ^^ the semi-never ending bouncing ball Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 28, 2016 Share Posted March 28, 2016 hmm, well done. You win. So why isn't THIS thing working? http://www.babylonjs-playground.com/#BEFOO#5 I must have a mistake in there somewhere. hmm. Ohhh... duh Wingy... box imposter on the sphere. Brilliant. Ok, never mind me... no backwards compat issue seen... but much Wingy stupidity seen. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 28, 2016 Share Posted March 28, 2016 6 minutes ago, Wingnut said: hmm, well done. You win. So why isn't THIS thing working? http://www.babylonjs-playground.com/#BEFOO#5 I must have a mistake in there somewhere. hmm. Ohhh... duh Wingy... box imposter on the sphere. Brilliant. I have done the exacts opposite before, I had a sphere on a box and I could not for the life of me understand why it behaved the way it did lol Wingnut 1 Quote Link to comment Share on other sites More sharing options...
ian Posted March 29, 2016 Author Share Posted March 29, 2016 Pryme8, OK 1.) ground.setPhysicsState( BABYLON.PhysicsEngine.MeshImpostor, { mass: 0, restitution: 0 }); ball.settPhysicsState( { impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 2, restitution: 0 } ); OR 2.) perplexus.pBody = new BABYLON.PhysicsImpostor(perplexus, BABYLON.PhysicsImpostor.MeshImpostor, { mass: 0, friction: 0 ,restitution: 0 ,move: false }, scene); ball.pBody = new BABYLON.PhysicsImpostor(ball, BABYLON.PhysicsImpostor.SphereImpostor, { mass: 1, friction: 0.5 ,restitution: 0.5 ,move: true }, scene); I think that mass on ball is same no matter if I change ball mass to 1 or 5 or 15. Ball always behaves the same way. And you forget set gravity 10 or 5 or something. I have gravity set: scene.enablePhysics(new BABYLON.Vector3(0, -5, 0), new BABYLON.CannonJSPlugin() ); scene.gravity = new BABYLON.Vector3(0, -5, 0); ok gravity works OK, and mass works OK. Heavy ball and lighter ball with same gravity have same acceleration speed isn't it ? Quote Link to comment Share on other sites More sharing options...
RaananW Posted April 8, 2016 Share Posted April 8, 2016 Hi! I never noticed the question. sorry for the very late answer. Can you direct me to the point where backward-compatibility is broken? I tried the first Wingnut demo, and changing the restitution value seems to work. Just wanted to say - this demo is the first demo in the documentation - http://doc.babylonjs.com/overviews/Using_The_Physics_Engine#basic-physics-scene I think backwards-comp is a wonderful thing, but if you develop something new, use the new syntax, it is more... future proof Quote Link to comment Share on other sites More sharing options...
ian Posted August 16, 2016 Author Share Posted August 16, 2016 if you add sphere.physicsImpostor.applyImpulse And if sphere and ground have restitution is 0. After you add impulse to sphere. Sphere begin crazy buncing. OK upper playground works ok, until you don't add applyImpulse to sphere. (But in 2.4.0-alpha it works OK). Problem is wiht 2.4.0 release and 2.5.0-alpha version. How can we set RESTITUTION TO 0. I think that restitution=0 have some problem in physics. Can anybody check this? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 19, 2016 Share Posted August 19, 2016 Hi Ian. I once heard someone say... that any physics imposter param (such as mass, friction, resti)... is IGNORED if set to zero. Try setting your restitution to .00001 or similar, and let's see what happens. Write back if ya like... ping the wing by using @Wingnut blue label in your reply. Also, please please please... make playgrounds that show the issue, if you can. thanks! talk soon, be well. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 20, 2016 Share Posted August 20, 2016 Mass should only be a value between 1 and -1. friction and restitution can be 0, but if you really need 0 restitution you need to overwrite the y velocity to 0 on a grounded state or when a collision happens with the ground. These go over this issue of a physics controller on the bottom. It's kinda badly strucutred but you'll get the idea by checking out these two scripts: https://github.com/Pryme8/Magic_Marble/blob/gh-pages/editor.html https://github.com/Pryme8/TERIABLE/blob/gh-pages/Infinity/teriable-infinity-0.0.1.js the one problem I'm running into is browser shortcuts but I think if I give the app focus that won't be a problem... I may change the crouch key from ctrl to shift for now to get around the ctrl-w issue. Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 21, 2016 Share Posted August 21, 2016 Mass should be a positive value, or 0 if the body shouldn't move. It can be a high number, the physics engine will take that into account when calculating the collisions. As Wingnut said, there is a small problem with restitution:0 when using the old (deprecated) API (setPhysicsState). Try using the new one, see if it works. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 21, 2016 Share Posted August 21, 2016 it does Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 22, 2016 Share Posted August 22, 2016 So my recommendation to everyone - use the new API. Old = deprecated. I will do my best to find time to fix the bug, so the old will work as well, but the new is so much better, as it provides a lot more freedom in configuring your physics scene. Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 22, 2016 Share Posted August 22, 2016 btw - I don't see the problem here - http://www.babylonjs-playground.com/#BEFOO#31 seems like it is working. doesn't it? Quote Link to comment Share on other sites More sharing options...
ian Posted August 26, 2016 Author Share Posted August 26, 2016 Here se was a problem with blender collisions export. I remove all rigid body from blender export ti Babylon File. Add all physic Code in Code and all work ok. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 26, 2016 Share Posted August 26, 2016 wow i did not even know you could attach physics bodys to and babylon export from blender. I feel like Im missing out on a whole world of stuff for babylon by using c4d instead. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
ewanvalentine Posted September 19, 2016 Share Posted September 19, 2016 Just out of curiosity, if I set mass to 0, on an object I want to be static. Moveable objects, or objects with a mass of 1 or more, are now able to pass through the static object. In other words, a mesh seems to lose all of it's physics completely. Unless I've misunderstood something. Here's an example! http://www.babylonjs-playground.com/#OYE6Q#4 Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 19, 2016 Share Posted September 19, 2016 Forcing a position might not work, as the physics engine will simple accept it, especially with objects that have no mass. It is possible to update the position, and the physics engine will simply decide when to "eject" the object away from the collided object. like this - http://www.babylonjs-playground.com/#OYE6Q#7 The best would be to actually use impulse, force, or set the linear velocity of the object - http://www.babylonjs-playground.com/#OYE6Q#6 Also - try using the new API wherever possible. thou backwards compatible, it is much easier to debug the new one. Quote Link to comment Share on other sites More sharing options...
ewanvalentine Posted September 20, 2016 Share Posted September 20, 2016 @RaananW I think I understand what you're saying, so things like 'animate' and simply changing the position are ignored by the actual physics engine. In your examples, the box moves around erratically and jumps all over the place. Is there away to just make it move from its current position, to a picked point, smoothly? Thanks so much for you help! I'm a complete n00b to game dev, and Babylon. Cheers, Ewan Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 20, 2016 Share Posted September 20, 2016 Hi, the first sentence is not entirely true. the position is not ignored by the physics engine, but is forced upon it. It simply has to "accept" the fact that you want the box there, but it will try doing its thing to keep physics going. So if you force the boxes to collide, it will "eject" one of them out in the next frame. that is, unless you keep on forcing a different position. So - you are the master, you decide where everything goes, but you also need to understand that this is bothering the rest of the components doing their job. About the example - it is moving in the direction I "ordered" it to. I applied an impulse, and it moves in this direction. You can use the linear velocity feature to force a move in a certain direction, or use forces / impulses. That's the best way to do that with a physics engine. Sadly animations or not so physics friendly. 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.