Example of my code:

var collisionConfiguration = new bullet.Bt.DefaultCollisionConfiguration();
var dispatcher = new bullet.Bt.CollisionDispatcher(collisionConfiguration);
var broadphase = new bullet.Bt.DbvtBroadphase();
var solver = new bullet.Bt.SequentialImpulseConstraintSolver();
var dynamicsWorld = new bullet.Bt.DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);

var groundShape = new bullet.Bt.StaticPlaneShape(new bullet.Bt.Vector3(0, 1, 0), 1);
var groundTransform = new bullet.Bt.Transform();
groundTransform.setOrigin(new bullet.Bt.Vector3(0, -1, 0));
var centerOfMassOffsetTransform = new bullet.Bt.Transform();
var groundMotionState = new bullet.Bt.DefaultMotionState(groundTransform, centerOfMassOffsetTransform);

var groundRigidBodyCI = new bullet.Bt.RigidBodyConstructionInfo(0.01, groundMotionState, cast groundShape, new bullet.Bt.Vector3(0, 0, 0));
var groundRigidBody = new bullet.Bt.RigidBody(groundRigidBodyCI);

var fallShape = new bullet.Bt.SphereShape(1);
var fallTransform = new bullet.Bt.Transform();
fallTransform.setOrigin(new bullet.Bt.Vector3(0, 50, 0));
var centerOfMassOffsetFallTransform = new bullet.Bt.Transform();
var fallMotionState = new bullet.Bt.DefaultMotionState(fallTransform, centerOfMassOffsetFallTransform);

var fallInertia = new bullet.Bt.Vector3(0, 0, 0);
// fallShape.calculateLocalInertia(1, fallInertia);
var fallRigidBodyCI = new bullet.Bt.RigidBodyConstructionInfo(1, fallMotionState, fallShape, fallInertia);
var fallRigidBody = new bullet.Bt.RigidBody(fallRigidBodyCI);

for (i in 0...3000) {
    dynamicsWorld.stepSimulation(1 / 60);

    var trans = new bullet.Bt.Transform();
    var m = fallRigidBody.getMotionState();

It's a haxe port for Bullet3, but I think all components and the concept/logic remains the same as in c++. The idea is that the fallShape should bounce against the groundShape. But it doesn't. When printing the trans.getOrigin().y() it goes it to negative numbers. So what am I doing wrong?


1 Answer 1


Setting mass for static ground to 0

var groundRigidBodyCI = new bullet.Bt.RigidBodyConstructionInfo(0.0, groundMotionState, cast groundShape, new bullet.Bt.Vector3(0, 0, 0));

and enabling fallShape.calculateLocalInertia(1, fallInertia);

worked for me!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .