Can BABYLON.6DoFConstraint be used for a solitary physics body? (e.g. to prevent a physics body from tipping over?)

Curious if BABYLON.6DoFConstraint could be created for a solitary physics body (i.e. not attached to another physics body) to better constrain that physics body’s movement. After that 6DoFConstraint was created, could one then:

physicsBodyA.addConstraint(physicsBodyA, newlyCreated6DoFConstraint) ?

If so, could someone create a brief example of how I would set that up (e.g. prevent box from tipping over in a constrained axis when a force is applied)


(If not, I welcome any suggestions of other ways in Havok physics can constrain a physics body’s movment)

It doesn’t really make sense to have a constraint without 2 bodies.
But you can create a static body (or a kinematic one) and add a constraint with a dynamic body.

Thanks, @Cedric.

I understand that Havok physics using the term “constraint” to refer to what box2d calls “joints”. My intention was not to use such joints/constraint objects but instead to constrain (in the general sense of the word) movement of my physics body when acted on a force. It seemed that other engines I read about (e.g. Unity) online have a way of constraining movement of a single physics body:

You can also change the position/orientation of the physics body each frame with your own computation

If you want to prevent rotation you can set body inertia to 0,0,0 with setMassProperties method

Thanks, @Cedric and @Olivier_Arguimbau.

Was really hoping to use forces/impulse to move body. I did previously try setting body inertia to 0,0,0 and my physics body still seemed to tip over when applied but will try gain and this time make it into a playground so can post if not working. :+1:

I made a mini-game as a physics test for my students a while , you can check the code here (forces and impulses) :

or this one :

(more complicated it’s a floating character controller implementation…almost working)


Cool, @Olivier_Arguimbau, I got it to work!

What i did differently was to use the:
physicsBody.setMassProperties({inertia: new BABYLON.Vector3(0,1,0)}) function [since I still wanted my physicsBody to rotate easily in the Y axis]

instead of what I was doing of trying to which was to try and insert the inertia setting property into the physicsAggregrate constructor

However, was a little tricky after that. Initially, the physics body didn’t seem to move at all in the X,Z plane when I applied the impulse that usually moved physicsBody (after setting the inertia to 0,1,0 so thought it wasn’t working). I then realized I could get the physicsBody to move with the inertia at 0,1,0 by applying a much higher impulse (for my project, I ended up needing to apply 100x the strength of the impulse to get the same apparent movement as if I hadn’t set inertial to 0,1,0. I can now play around with the inertia numbers to get what I want but my physics body definitely doesn’t tip over.

Does the range of values for inertia go from 0 to 1? It would probably be helpful to others if the “inertia” feature was explained a bit more in the documentation; I see on the forum that multiple people have asked similar questions on how to prevent their physics bodies form tipping over. A playground might also help. (I’ll try to come up with a playground for that once I figure out more about how inertia works in my project).

Regarding your example projects: I git cloned the first repository you linked but couldn’t get the project to run. I found one index.html file in the public folder that I tried to run using a local host static server but that seemed like a simple .html file that didn’t link all of the .js files together so don’t show me anything except for a blank screen with a counter. At your convenience, could you explain briefly further how to get your project that you linked to run?



Cool news. For your project depending on what you expect you can just rotate the mesh on y and not the body.

And for my repo, you need to run npm install and then npm start to test it.

All my projects are packages and use webpack

Edit: all is explained in french (add subtitles
If needed) here :

And here :

Perfect, thanks again, @Olivier_Arguimbau.

Since I’m trying to use forces to move the player, I figured I’d get more consistent results if I on my physics body I setAngularVelocity (along with angularDampening). However, since the API doesn’t specifically include angularForce or angularImpulse, I understand your point that I could just as well just rotate the body.

Have a good rest of your week.