Can you set objects to be unaffected by gravity?

Jan 18, 2008 at 6:20 AM
Is it possible to toggle gravity off for certain objects in a scene?

Or as an alternative I was thinking of adding a force that is opposite to gravity for those objects, but I wasn't sure how to do that.

This is a snippet of code from my test game (where my sphere object class is similar to the one in the jiglibx demo):

SphereObject so = new SphereObject("sphere", 1f, new Vector3(0f, 3f, 0f), Quaternion.Identity, new MaterialProperties(2f, 0f, 0f), this);
so.Body.ApplyWorldImpulse(Vector3.Right * 50f);
//so.Body.Force += new Vector3(0f, -10f, 0f);

The ApplyWorldImpulse works (so my body is responding to forces, but only as an impulse), but the commented line didnt have any effect. I also tried AddBodyForce and AddWorldForce but those had no effect either. Could you give me an example of how to add a force?
Jan 18, 2008 at 1:16 PM
Hi, just derive a class from the Body class and overwrite: public virtual void AddExternalForces(float dt).
There the force is normally set. So if you don't want any gravity just overwrite it and do not apply any forces.