I am new to c++ as well as game development. I coded a function using bullet physics which returns the gravity of the world and it seems to be not working. It always returns 0. Though, I've initialized the world, solver, dispatcher, broadphase and collision configuration.
Here's the code:
void _setGravity(btScalar gravity) //sets the gravity of the world
{
if(gravity > 0.f)
gravity = -gravity;
_dynamicsWorld->setGravity(btVector3(0, gravity, 0));
}
btScalar _getGravity(void) //returns the gravity of the world
{
return ((btScalar*)_dynamicsWorld->getGravity());
}
Is there something that I am doing wrong ?
Thank you.
static_cast
. If you needreinterpret_cast
to make it compile, you probably have a bug. – Neil Kirk(A*)a->x()
; which is 1st->
or cast ? – luk32