Question

Sorry if there is another thread like this one, but i cannot find a solution..

I have a box2d game and i need to make one body to collide ONLY with the player and nothing else. Can you help me? How to define the mask bits, or the groups?

Était-ce utile?

La solution

I found a solution (i write on LibGDX). I use setContactFilter(). I implemented this interface and override shoudCollide()

public class BackgroundContactFilter implements ContactFilter {
 @Override
 public boolean shouldCollide(Fixture fixtureA, Fixture fixtureB){
  return false;
 }

}

All interactions are disabled with this code.

I hope that this would be helpful to someone.

Autres conseils

Heres a great article that will walk you through everything you need to know about masks and groups:

http://www.aurelienribon.com/blog/2011/07/box2d-tutorial-collision-filtering/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top