1
votes

I am developing a game using LibGDX platform and box2D in which I am moving one body(Dynamic) with the help of tocuhPad motion of LibGDX using

testBody1.setTransform(new Vector2(x,y), 0);

method and there are another bodies(Static) on the way with which the dynamic body collide.What I want is that when my dynamic body collide with the static one, none of them will overlap with each other that is not happening yet. Right now they are overlapping each other by applying force and moving static body.So, how can I prevent the collision of both bodies?

2

2 Answers

0
votes
testBody1->SetLinearVelocity(b2Vec2(0, 0));
0
votes

You can do one thing that you check when your dynamic body collide with static body in BeginContact method. As they collide then you set dynamic body speed zero.