Jump to content

Oimo.Body


Robin
 Share

Recommended Posts

Background: I am reading the Babylon.js ebook - Chapter9 Collision, and find a line of code: var body = mesh.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {mass:0, restituion:0.5, friction:0.5});

This function will return an instance of the rigid body, i.e. Oimo.Body.  However, I run the code, and an error is raised, says the function setPhysicsState is undefined.

Question 1:  Is that true the function is removed from API forever?

Question 2: Once physics impostor is added to a mesh, e.g. sphere.physicsImpostor = new BABYLON.PhysicsImpostor(...), how can I move this mesh? Do I have to apply an impulse to the mesh or I can simply update the mesh position, such as sphere.positon.z += 1?

 

Thank you.

 

Link to comment
Share on other sites

1)

Yes. The API has changed to:

sphere.physicsImpostor = new BABYLON.PhysicsImpostor(sphere, BABYLON.PhysicsImpostor.SphereImpostor, { mass: 1, restitution: 0.3 }, scene);

2)
You can do both. But physics-engines prefer forces or impulses. You Can change the positions, but you "might" get into various issues with clipping through objects and the sorts.

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