Вопрос

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?

Это было полезно?

Решение

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.

Другие советы

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/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top