# removing box2d objects before collision occurs

I am having a problem with a collision detection between the character and items, both created as box2d objects. What I am trying to do is to delete the item or remove item from the collision method before character hits item and bounces away. Thus, I want to detect when the item and character collided to gain item effects.

Current sources are as below :

mWorld.setContactListener( new ContactListener() {
@Override
public void endContact(Contact contact) {
}
@Override
public void beginContact(Contact contact) {
Body bodyA = contact.getFixtureA().getBody() ;
Body bodyB = contact.getFixtureB().getBody() ;

Box2DUserData dataA = (Box2DUserData) bodyA.getUserData() ;
Box2DUserData dataB = (Box2DUserData) bodyB.getUserData() ;

if( dataA.id == Box2DUserData.ID_ITEM ) {
//mWorld.destroyBody(bodyA);
//bodyA.setTransform(new Vector2( 0, 0 ), 0 ) ;
bodyA.setActive(false );
}
else if( dataB.id == Box2DUserData.ID_ITEM ) {
//bodyB.getWorld().destroyBody(bodyB);
//bodyB.setTransform(new Vector2( 0, 0 ), 0 ) ;
//mWorld.destroyBody(bodyB);
bodyB.setActive(false );
}
}
});


This source works okay, but the bodies are removed after collision detection. So I can get the character walk through items, after the character bumped in item and stopped for a frame or so.

I am not sure if I am supposed to use World.setContactListener or another method, it would be grateful if someone could give me the right method or another way to detect collision and the way to remove body from collision method before it actually collides.

Thanks