Hi,
I have 2 characters in my game each has a character control and dynamic anim control with a few linked joints.
I would like the character control of player1 to ignore the other player’s joints so it will pass through it unlike the behavior demonstrated in the below pic.
So , I have tried to add each player’s character control to the other player joint’s rigid bodies ignore list (see code below) but it doesn’t help.
However, addToIgnoreList() works on collision objects, not controls. To access the collision object of a CharacterControl, use the getCharacter() method. To access the collision objects of a DynamicAnimControl, use the listRigidBodies() method.
Alternatively, there are also ways to ignore collisions using collision groups.
I have not tried the “addToIgnoreList” method. I also use the Minie physics engine in my game. I have both BCC (BetterCharacterControl) and DAC (DynamicAnimControl) enabled for my character. In order to avoid them from colliding, I have them Set up a different CollisionGroup and so far this works great.
Thank you @sgold . Maybe I’m missing something but isn’t it exactly what I did in my code?
I got the CharacterControl using getCharacter() and then fetched all collision objects by calling listRigidBodies() and then added to each of the collision objects to the Character control’s ignore list.
I can try switching to another method but I would like to know if adding to ignore list should get the same results if done correctly.
I can try creating a test app for this case if it helps.
Thanks @FoxCC . I need to read about BetterCharacterControl see maybe it’s better using it in my game. I will try switching to using different collision group if we find that the described method I’m currently using is not supposed to work even if done correctly.
OK, I tried switching to using different collision groups for the CharcaterControl’s collision object and the Joints rigid bodies but still - no effect. So, I’m writing a test app to demonstrate the problem
I created a test app simulating the situation.
I tried to have each character control ignore the other’s player joint’s rigid bodies but still the character control’s collision shape is stopped when colliding with the joints.
Hope it helps to understand the problem…
I didn’t try yet to use BetterCharacterControl instead of CharacterControl.
I ran your test case and I didn’t test why “addToIgnoreList” didn’t work.
I made a simple modification and set up different CollisionGroup for them. The effect is like this. I don’t know if this is what you want.
this.player1 = loadPlayer(new Vector3f(0,-6,0), 2); // Load player with collisionGroup = 2
this.player2 = loadPlayer(new Vector3f(0,1,0), 3); // Load player with collisionGroup = 3
// ignoreJoints(this.player1, this.player2);
// ignoreJoints(this.player2, this.player1);
......
charCtl.getCharacter().setCollisionGroup(1 << collisionGroup);
for (int i = 0; i < rbs.length; ++i) {
rbs[i].setCollisionGroup(1 << collisionGroup);
}
You can also set it up more complexly,
Then BCC objects will collide with each other.
int normalGroup = 1;
int bccGroup = 2;
int dacGroup = 3;
charCtl.getCharacter().setCollisionGroup(1 << bccGroup);
charCtl.getCharacter().setCollideWithGroups(normalGroup | (1 << bccGroup));
for (int i = 0; i < rbs.length; ++i) {
rbs[i].setCollisionGroup(1 << dacGroup);
}
I just found out that it’s better to use these constants from PhysicsCollisionObject.
int normalGroup = PhysicsCollisionObject.COLLISION_GROUP_01;
int bccGroup = PhysicsCollisionObject.COLLISION_GROUP_02;
int dacGroup = PhysicsCollisionObject.COLLISION_GROUP_03;
charCtl.getCharacter().setCollisionGroup(bccGroup);
charCtl.getCharacter().setCollideWithGroups(normalGroup | bccGroup);
for (int i = 0; i < rbs.length; ++i) {
rbs[i].setCollisionGroup(dacGroup);
}
Apparently, ignore lists have no effect whatsoever on physics characters. This is (even more) obvious in simple tests like HelloWalkOtoCc which have only 2 collision objects in the space. I consider this a bug in Bullet.
I’m developing a fix. For now you should use collision groups instead of ignore lists and/or use BetterCharacterControl instead of CharacterControl.