Sign in to follow this  
Robin

Oimo.Body

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.

 

Share this post


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

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.