java Box2d过滤掩码,组类别
我有两个身体定义,创建:身体A和身体B,以及连接它们的关节
我希望主体A只有在它们链接时才能与主体B碰撞
同时,一个主体B不能碰撞另一个主体B,一个主体a不能碰撞另一个主体a
a身体B不能碰撞与他无关的身体a
我可以分配什么掩码、类别和组?我迷路了,我不明白
你可以在下面搜索框中键入要查询的问题!
我有两个身体定义,创建:身体A和身体B,以及连接它们的关节
我希望主体A只有在它们链接时才能与主体B碰撞
同时,一个主体B不能碰撞另一个主体B,一个主体a不能碰撞另一个主体a
a身体B不能碰撞与他无关的身体a
我可以分配什么掩码、类别和组?我迷路了,我不明白
# 1 楼答案
可能有几种方法可以实现这一点,但我想到的一种方法是: 设置类别和过滤器,使A和B通常不会碰撞
接下来,用一个正整数为每对对象指定其唯一的组id。这将确保组内的对象彼此碰撞,而不考虑A和B的正常规则,而不同的组将使用正常规则(因此不会碰撞)
组对象的构造函数可以采用组id,然后
然后创建每个组