Jump to content

can't get physics to work right


davidbeccue
 Share

Recommended Posts

Hi,

I imported a mesh and then separated it into two objects.  Basically a wheel and a stand for the wheel.  And I want the axle for the wheel to fall onto the stand and allow me to spin the wheel.

My problem is that I can't get the physics to work right.   I either drop things through the floor or gravity doesn't work at all, depending on the different engines and things I've tried.

I'm new to babylonjs so perhaps I'm doing wrong something that's simple to see.

My code is at  http://www.babylonjs-playground.com/#2I8LFS#2   If anyone can see what I'm doing wrong, I'd much appreciate it!

Link to comment
Share on other sites

Hi,

To get the physics working properly you will have to run the physics code after loading the meshes. Otherwise the bodies generated using the physics engine won't be correct.

To get you started - http://www.babylonjs-playground.com/#2I8LFS#5

I am not sure which mesh is mesh, but if you want to simplify the scene and add a few comments, I will be able to help better.

Link to comment
Share on other sites

I tried to simplify and comment.   But now I get a compilation error seemingly related to getElemetById() which I don't see anywhere in my code.

And I had previously put an alert() in the code to ensure the mesh gets loaded before I let it proceed to creating imposters.   But even with your fix of doing physics imposter creation at the end of the mesh loading, I don't see objects using gravity and falling to the plane.

 

I have a simple sphere and cylinder for testing, along with my complicated mesh.   And those test objects don't fall either.   Must be something simple I'm doing wrong.

 

Also am I able to use the Oimo engine in the playground?

Link to comment
Share on other sites

  • 4 weeks later...

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