[SOLVED] How to make CharacterControl And DynamicAnimControl Ignore Each other?

Hello,
I would like my CharacterControl and my DynamicAnimControl to ignore each other so I thought I could write something like this:

if(myDynamicAnimControll!=null) {
    for(int i=0;i<myDynamicAnimControl.listRigidBodies().length;++i) {
        myCharacterControl.getCharacter().addToIgnoreList(myDynamicAnimControl.listRigidBodies()[i]);
        myDynamicAnimControl.listRigidBodies()[i].addToIgnoreList(myCharacterControl.getCharacter());
    }
}

But it seems that it is not working… They still affect each other and I get unexpected behavior.
Am I doing it right?

Thanks!

2 Likes

That code looks fine. Is it executed while the DAC is added to a Spatial? What is the value of myDynamicAnimControl.listRigidBodies().length?

1 Like

The length is 13 (I’m using the regular green Ninja model for my test).
I used to overcome this issue by using collision groups but I have noticed that I’m no longer having collision events between kinematic objects (like sphere) and the Ninja. I’m almost sure that it stopped working since Minie 2.0 but I was surprised that the collision worked in the first place so I guess that Minie 2.0 fixed a bug which causes the collision not to work now (as expected) so I removed the collision group code and as expected I’m getting collision events again but now CharacterControl and DAC rigid bodies are affecting each other again and addToIgnoreList() doesn’t work in my case

2 Likes

The code is executed after the DAC is added to the Spatial

I’d expect kinematic bodies to disturb Ninja’s DynamicAnimControl, but only for links that are in dynamic mode.

I haven’t actually tested ignore lists with CharacterControl yet. Perhaps that’s the root of your issue.

I’d welcome some simple test cases I could run.

2 Likes

I’ll try to make a sample code and also try rolling back to 1.7 see if its really something new that came up with 2.0

1 Like

I have assembled a simple test case. Here is a link for the source code:

Notice that even when setting the CharacterControl and DAC rigid bodies to ignore each other , the CharacterControl is “flying” away from the ground. This is not happening when using collision groups but then again you loose collision events.

Expected results : when using the above sample ignore list the CharacterControl tries to fall to the ground and not fly away from it

1 Like

@oxplay2 appeared to get it working haven’t tried it though

Blockquote i found reason why physics groups were not working for me(just for DAC):

need to set them BEFORE line

dac.setPhysicsSpace(physicsSpace);

if groups are set AFTER this line, it just dont work.

perhaps he will confirm any issues

Thanks for the test case. That saves me a lot of guesswork!

I’ve reproduced the issue you described. I’m convinced it’s a bug in Minie, but haven’t yet determined the root cause. I suspect Bullet doesn’t implement ignore lists for characters. If so, I may be able to fix it in a patch release.

Edit:
Indeed, Bullet doesn’t implement ignore lists for characters.

I’ve developed a patch. I’ll release it as Minie v2.0.1, probably in a day or 2. But first I want to check whether there are similar issues with soft bodies and ghost objects.

2 Likes

Amazing! thanks a lot!

1 Like

Collision groups are working fine for me. I thought Minie 2.0 introduced a regression when using collision groups - I didn’t get collision events but it was a bug in my code and now it works.
Anyway collision ignore list is IMO a better way for CharacterControl and DAC rigid bodies to operate good together.

1 Like

Here’s what I’ve learned about the underlying issue:

Bullet 2.89 implements ignore lists for rigid bodies and probably for multi-body colliders too. But they are ignored by ghosts and characters, and probably by soft bodies as well. The simplest fix is to add the check to “jmeCollisionSpace.cpp”, which is “glue code”—not part of Bullet at all!

For vehicles, ignore lists affect the chassis (which is a rigid body), but not the wheels (which are simulated using raycasts). Implementing ignore lists for wheels properly would involve extensive changes to Bullet. Instead, I plan to document this limitation and move on.

The issue with vehicle wheels makes me concerned about BetterCharacterControl, which also uses raycasts. Fortunately, BetterCharacterControl can be easily remedied in Java.

2 Likes

I’m glad you’re able to do your thing with collision groups. I agree with you that ignore lists are a better solution in this case.

I’ve released Minie v2.0.1 with the fix for the ignore-list issue. It seems to solve the problem in the TestApp you uploaded. Please let me know whether it does what you want.

1 Like

Thank you so much Stephen! I’ll try using it today.

1 Like

@sgold I’m starting testing 2.0.1 and it looks like ignore lists are working just fine! I removed all the collision groups code and now i’m testing all kind of aspects looking for possible regressions.
One thing I have noticed is that Kinematic objects such as the Sphere in the attached movie is now pushing the Character control rather then passing through it. Either way I’m still getting collision events.
I’m not sure if it’s a bug or feature but its a major difference from previous versions of Minie.
WDYT?

1 Like

Also since Minie 2.0 no more application crashes due to your fix of the native finalize. Huge improvement!

1 Like

I’ve reviewed the release log. There was a bug that got fixed between 2.0.0-test2 and 2.0.0 involving initialization of characters; it caused many strange behaviors. Maybe that affected the behavior of your app.

In general, I think kinematic bodies should affect characters. Besides, it’s always easier to disable contact response than to add it.

If you want to investigate further, I’m game. You could try with 2.0.0-test2 OR you could send me another simple test app.

1 Like

Actually I think it’s cool that Character control now responds to kinematic bodies. I just wanted to make sure that it is by design because it will affect my games code and I probably a lot of other JME users…

2 Likes