saharan / OimoPhysics

A cross-platform 3D physics engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: What is the equivalent of setLinearFactor() in bullet physics?

MiloHX opened this issue · comments

commented

Hi! Thanks for the wonderful physics engine!
I got a question: if I want to lock a specific axis of an object, in bullet I can use setLinearFactor() and set that axis to 0.0. In Oimo I found that there is setRotationFactor() for rotation, but I didn't find the equivalent for location. May I know what is the best way to achieve this?

Regards
Milo

Hello, thanks for using the library!
As you say, I haven't implemented setLinearFactor yet so there is no equivalent function in release 1.2.0. But there are a few ways to lock a specific axis of an object, and I recommend the following one:

  1. create a static rigid body to which the object (that you want to lock an axis) will be locked
  2. create a GenericJoint that connects the static rigid body and the object. By default, two objects are completely stuck and they cannot move or rotate along each other
  3. unlock all the rotational and translational limits except the axis you want to lock

Please note that simply assigning a constant to the object's location and velocity every frame will not work correctly, as it does not perform as a "physical constraint."

I hope this helps :)

commented

I think I got the answer, case closed & thank you!