How to set a rigid body in 3d position [SOLVED]

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
Alberto García
Posts: 2
Joined: Thu Oct 16, 2014 10:54 am

How to set a rigid body in 3d position [SOLVED]

Post by Alberto García »

I'm programming a simple minigolf, game, and I try to set the ball ( rigid body ) in the 0,0,0 position when the ball Y position is < -1. This is my code:

Code: Select all

            
btVector3 position( 0, 0,0 );
this->ball->bulletRigid->getWorldTransform().setIdentity();
this->ball->bulletRigid->getWorldTransform().setOrigin(position);
But the sphere is not set on 0,0,0 instead of this the ball disappears.
Last edited by Alberto García on Sat Oct 18, 2014 5:08 pm, edited 1 time in total.
Alberto García
Posts: 2
Joined: Thu Oct 16, 2014 10:54 am

Re: How to set a rigid body in 3d position [SOLVED]

Post by Alberto García »

Hi have solved it by myself with the following code:

Code: Select all

            
btVector3 position( this->lastPostion.X( ), this->lastPostion.Y( ), this->lastPostion.Z( ) );
btTransform trans;
this->ball->bulletRigid->getMotionState()->getWorldTransform( trans );
trans.setOrigin( position );
this->ball->bulletRigid->clearForces();
this->ball->bulletRigid->setLinearVelocity( btVector3( 0, 0, 0) );
this->ball->bulletRigid->setAngularVelocity( btVector3( 0, 0, 0) );
this->ball->bulletRigid->setWorldTransform( trans );
Post Reply