Vector
Vector

Reputation: 172

Box2D:How to make a body ignore gravity

I have set the gravity of my world as follows

world=new b2World(b2Vec2(0.0,9.8));

I have a dynamic body called b2Body* sta1 which is falling from the top of the screen. And I have another dynamic body sta2 which should not fall i.e it just move on some keypress. The problem is how can I give this body of my world zero gravity i.e is there any way to give different gravity values to different bodies in the world?

Upvotes: 0

Views: 1190

Answers (1)

NeoCJay
NeoCJay

Reputation: 36

yes you are right. You should set the gravity scale of the body defition.

   sta2def.gravityScale = 0.0f;

Upvotes: 2

Related Questions