Jump to content

[SOLVED]Physics not working.


Borislav
 Share

Recommended Posts

I try to make a ball move with collision but it doesn't work!

It does work with only one of the grounds.

Code:

    //ground
    var ground = BABYLON.Mesh.CreateBox("box",2, scene);
    ground.material = Mat2;
    ground.position.y = 1;
    ground.rotation.x = 4;
    ground.scaling.x = 10;
    ground.scaling.z = 0.125;
    ground.scaling.y = 10;
var ground2 = BABYLON.Mesh.CreateBox("box",2, scene);
    ground2.material = Mat2;
    ground2.position.y = -10;
    ground2.position.z = -10;
    ground2.rotation.x = Math.PI / 2;
    ground2.scaling.x = 10;
    ground2.scaling.z = 0.125;
    ground2.scaling.y = 10;
ground2.physicsImpostor = new BABYLON.PhysicsImpostor(ground2, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 0, restitution: 0.9 }, scene);
ground.physicsImpostor = new BABYLON.PhysicsImpostor(ground, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 0, restitution: 0.9 }, scene);
sphere.physicsImpostor = new BABYLON.PhysicsImpostor(sphere, BABYLON.PhysicsImpostor.SphereImpostor, { mass: 1, restitution: 0.9 }, scene);
return scene;

Please help!

Thank you, Borislav.

Link to comment
Share on other sites

http://www.babylonjs-playground.com/#OB0LJ#14

I have problems, too.  (I did some adjusting and reduced gravity much)  Looks like invisible impostors are there.  hmm.

I will keep thinking, and do more tests.  Stay tuned.

update:  working better in BJS 2.5 version of playground:  http://www.babylonjs-playground.com/index2_5.html#OB0LJ#14

hmm.  Ooops... the 2.5 playground SAVE isn't working, or I'm doing it incorrectly.  hmm.  Just paste the code from the first URL, into the blank second URL editor, and hit run.  Better ball bounce.  :)

Link to comment
Share on other sites

On 09.04.2017 at 6:28 AM, Wingnut said:

http://www.babylonjs-playground.com/#OB0LJ#14

I have problems, too.  (I did some adjusting and reduced gravity much)  Looks like invisible impostors are there.  hmm.

I will keep thinking, and do more tests.  Stay tuned.

update:  working better in BJS 2.5 version of playground:  http://www.babylonjs-playground.com/index2_5.html#OB0LJ#14

hmm.  Ooops... the 2.5 playground SAVE isn't working, or I'm doing it incorrectly.  hmm.  Just paste the code from the first URL, into the blank second URL editor, and hit run.  Better ball bounce.  :)

I am still having a problem. 

Link to comment
Share on other sites

Hi B!  Did you switch to BabylonJS version 2.5?  I think you should, for now.  Other versions are showing physics issues, such as the one you found.

I made another version of the non-2.5 failure.  http://www.babylonjs-playground.com/#OB0LJ#17

Still trouble, as you see. 

BUT, when I paste that code... into  http://www.babylonjs-playground.com/index2_5.html#OB0LJ#14 editor (a blank editor with 2.5 BJS as core)... and hit RUN... the physics look good again.

Try it.  Load this... you should see blank editor.  Paste code from THIS playground... into that blank editor, and click RUN.  Look ok?  Looks good on my machine.  Good ball bouncing, and I added an automatic "return ball to starting position" -feature... for when sphere falls too far.  :)

Unfortunately, I still cannot SAVE 2.5 version playgrounds.  BJS team is working-on that issue right now.  But, you should use BJS 2.5 for now (for non-playground or at-home projects)... so your physics work correctly. 

Stay in touch, tell us progress, please.  thx.  Let's ping physics expert @RaananW, in case he wants to monitor our conversations.  Talk again soon.

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...