Applying a impulse to a rigidbody that has no gravity

chadberk
Posts: 6
Joined: Fri Sep 14, 2012 3:14 am

Applying a impulse to a rigidbody that has no gravity

Post by chadberk »

I would like to apply and impulse force to a rigid body that has its gravity set to (0, 0, 0). I was doing this by just calling applyCentralForce and that will work, but only if there is gravity. Is there another way to apply an impulse when there is no gravity on a rigid body?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Applying a impulse to a rigidbody that has no gravity

Post by Erwin Coumans »

Your rigidbody is likely deactivated. You can manually activate the object, before applying the impulse

Code: Select all

object->activate();
Or you can disable de-activation using

Code: Select all

object->setActivationState(DISABLE_DEACTIVATION);
chadberk
Posts: 6
Joined: Fri Sep 14, 2012 3:14 am

Re: Applying a impulse to a rigidbody that has no gravity

Post by chadberk »

Thank you, that seems to have fixed the issue.

When would be the best time to call activate? I noticed that if I just call "activate" after I set the gravity that it will still not be active. It seems I need to call active every time after an impulse is added.

Perhaps there is a better what to achieve what I would like to do.

I would like to have an object that just moves in space while not being pushed down, which occasionally takes an impulse. Is there a better way to achieve this?