Sign in to follow this  
Borislav

[SOLVED]Physics not working.

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.

Share this post


Link to post
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.  :)

Share this post


Link to post
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. 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Hey guys,

this is happening due to a new way to calculate the extend size of the object. So far it worked correctly, the problem here is the rotation (that should be supported, of course).

A quick solution is this - http://www.babylonjs-playground.com/#OB0LJ#19

I will work on a global fix for the entire framework.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.