I am making a game using AndEngine and Box2D. I am making a pong style football game and I want keeper to act like a static body when ball collides with it. When they collide keper moves too and it makes my game unplayable. I have tried to do something using contactListener but it doesnt work.
Asked
Active
Viewed 1,250 times
2 Answers
1
Set the body type of the keeper as Kinematic
.
A kinematic body is an hybrid body which is not affected by forces and collisions like a static body but can moved with a linear velocity like a dynamic body.
You can move it, but if it gets hit by a ball it wont move.

LordRaydenMK
- 13,074
- 5
- 50
- 56
-
I forgot to say that the keeper must stay between two goal posts. So keeper must collide with that posts – Arda Kara Jun 29 '14 at 16:35
-
-
I tried it but it doesnt worked. It is so weird :/ I found a solution but it isnt good enought. I set a friction joint with a big friction value. So it stop moving just after collision but it moves a bit. When I want to move keeper myself I set velocity continuesly while key pressed But as I said it moves a bit after collision so it is not a perfect solution – Arda Kara Jun 29 '14 at 21:03
-
I'm assuming the goal post don't change position. Why would it be hard to limit the keeper X/Y position? – LordRaydenMK Jun 30 '14 at 09:54
-
I dont know but I tried that code but if doesnt help: if( post[0].getX() < keper.getX() && post[1].getX > keper.getX()) //move keeper – Arda Kara Jun 30 '14 at 10:33
-
I have changed all of my onAreaTouched methods and I applyForceToCenter instead of setting velocity directly and it worked. Thanks for your help – Arda Kara Jun 30 '14 at 11:38
0
Why don't you do the keper body type static? That way it will have infine mass and not move, read more here.

user1223333312
- 168
- 7