Page 1 of 1

SimpleCharacterController slipping slightly beneath surface

Posted: Mon Apr 29, 2013 11:31 pm
by Telanor
I'm having an issue with the SimpleCharacterController jumping and then landing with its bottom edge ever so slightly beneath the surface of the terrain. It ends up getting stuck in a "no traction" mode because the raycast doesn't detect any ground beneath it. I was under the impression that the terrain usually pushes interpenetrating objects out. How come that isn't happening here?

Re: SimpleCharacterController slipping slightly beneath surf

Posted: Mon Apr 29, 2013 11:41 pm
by Norbo
It attempts to correct it up to an allowed penetration threshold, CollisionDetectionSettings.AllowedPenetration, which defaults to 0.01. This is needed to avoid jitter in the pairs that do not use speculative contacts.

You could start the ray a bit earlier to deal with this issue with the SimpleCharacterController, but this is far from the only problem with the SimpleCharacterController. It's just not a robust character.

If you seek performance: the 'simple' in SimpleCharacterController refers to the conceptual simplicity, not so much computational simplicity. A SphereCharacterController will probably perform better. It's been a while since I benchmarked it, but the full CharacterController is probably a little faster than the SimpleCharacterController on average too.

Re: SimpleCharacterController slipping slightly beneath surf

Posted: Mon Apr 29, 2013 11:58 pm
by Telanor
Hmm, well I'm using it for NPCs, and there could potentially be a bunch of them. The sphere controller would probably make it too difficult for NPCs to fit through areas they should fit in. Should I just use the full character controller then?

Re: SimpleCharacterController slipping slightly beneath surf

Posted: Tue Apr 30, 2013 12:09 am
by Norbo
If you had to choose between the SimpleCharacterController and the CharacterController, yes, I'd pick the CharacterController. The (Sphere)CharacterController supports multithreading out of the box, unlike the SimpleCharacterController, and of course is actually robust.

If you have a highly 'steppy' environment such that you find CharacterController step queries are eating up a lot of your frame budget, you can cut it down a bit by disabling the character's downstepping routine. It's actually more expensive than upstepping and disabling it isn't a problem for most games.

To disable it, just remove the TryToStepDown call in the CharacterController at this line:

Code: Select all

                if (StepManager.TryToStepDown(out newPosition) ||
                    StepManager.TryToStepUp(out newPosition)) ...
There's also another alternative: make a 'Capsule'CharacterController. It wouldn't be quite as fast as a SphereCharacterController, but it would still be pretty darn fast and the capsule's rounded bottom would handle stepping over small objects without needing an actual stepping implementation.

To make such a character, you could use either of the existing characters as a basis. In fact, you could approximate a capsule by just setting a regular CharacterController's cylinder width to something real small while giving it a large collision margin. Then, you could disable both up and downstepping and let the curved bottom handle it.

Re: SimpleCharacterController slipping slightly beneath surf

Posted: Tue Apr 30, 2013 4:28 am
by Telanor
I'll go with the CharacterController for now then and look at changing it later if it becomes a problem then. Thanks norbo