0
\$\begingroup\$

I have a rigid body component which has a field named enableGravity. This flag is synchronized with Physx objects before simulation:

rigidBody.actor->setActorFlag(PxActorFlag::eDISABLE_GRAVITY, !rigidBody.dynamicDesc.applyGravity); rigidBody.actor->wakeUp(); 

Once the gravity starts, I am not able to disable it. I tried to apply the "negative" gravity to it when gravity is disabled:

if (!rigidBody.dynamicDesc.applyGravity) { rigidBody.actor->addForce(-mScene->getGravity()); } 

But this does not zero out the force either.

\$\endgroup\$
3
  • \$\begingroup\$ I don't know PhysX. So you do disable the gravity flag? When doing so, I presume you want the object to stop falling? I presume having the gravity enabled will add force to the object every frame. Then maybe setting the forces and velocities to zero once when you disable its gravity could help stop the object? \$\endgroup\$ Commented Mar 29, 2022 at 21:04
  • \$\begingroup\$ Thank you! I will check it out. My only concern is that, when I clear all the forces, even the non gravity forces will be cleared out. \$\endgroup\$ Commented Apr 2, 2022 at 6:50
  • \$\begingroup\$ If you add gravity for 30 frames, presumably, to cancel its effect you'd need to apply negative gravity it for 30 more frames? \$\endgroup\$ Commented Apr 2, 2022 at 10:34

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.