CharacterController stuck problem

Discuss any questions about BEPUphysics or problems encountered.
J2T
Posts: 48
Joined: Sat Sep 20, 2008 6:20 pm
Contact:

Re: CharacterController stuck problem

Post by J2T »

That sounds good. I'll do my best to reduce the whole solution to minimum requirements...i will inform you tomorrow.

Thanks anyway.
J2T
Posts: 48
Joined: Sat Sep 20, 2008 6:20 pm
Contact:

Re: CharacterController stuck problem

Post by J2T »

Please check your PM Inbox...
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: CharacterController stuck problem

Post by Norbo »

Some good news and some bad news:

I have what appears to be a solution for the problems you were observing with the SimpleCharacterController, and fortunately, it's pretty easy:

1) StaticTriangleGroups/Terrains have a "tryToUseTriangleNormals" boolean in them that, if enabled (and it is enabled, by default), will use the triangle's normal in any collision whose normal is less than "useFaceNormalWithinAngle" radians away from the triangle normal. This helps smooth sliding motion across triangle boundaries generally. However, at sharp angles, the collision normals returned can be 'too' wrong. Specifically, when the character capsule falls off the side of a railing, a contact whose normal is completely vertical (matching the upper triangle's normal) may be created. The collision response system removes all velocity along that normal, stopping the capsule from falling further.

Since the character's raycast doesn't hit anything, you aren't able to do anything in this position and you get 'stuck.' You can either the StaticTriangleGroup's tryToUseTriangleNormals field to false, or reduce the useFaceNormalWithinAngle angle.

2) Once you have correct normals, friction may still stop the character from sliding off. You could set the friction of your entire group and character to 0 to solve this, though there is a better approach. Attach an event to the character's body cylinder of the "controller created" type. Set the new controller's friction to 0. This overrides the character's previously computed friction and lets the capsule slide off easily. Here's some sample code to do this.

Code: Select all

        //The event handling method...
        public void controllerCreated(Entity e, Controller newController)
        {
            newController.dynamicFriction = 0;
            newController.staticFriction = 0;
        }

        //Call this from the character controller constructor to hook the event
        body.addEventHook(new EventHandlerControllerCreated(controllerCreated));
The bad news is that I just discovered an annoying flaw with the latest version of the character controller I've been working on. It's going to require some significant work to get around, and it will probably need to wait until v0.10.0 is done.

On an unrelated note, if you needed better physics behavior other than your characters, it may be a good idea to shrink the world some more. I noticed when creating the boxes that they bounced and intersected the environment oddly. If the world was around 1/30th to 1/70th the size, most of these problems would disappear.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: CharacterController stuck problem

Post by Norbo »

And if you're curious, here's the newest character controller. It's better overall than the one prior to the SimpleCharacterController, but it is still possible to get it to stand on the edge between to triangles forming a wall. It doesn't happen always, it happens enough to be annoying.
Attachments
CharacterController0100.zip
(9.76 KiB) Downloaded 260 times
J2T
Posts: 48
Joined: Sat Sep 20, 2008 6:20 pm
Contact:

Re: CharacterController stuck problem

Post by J2T »

Norbo, thanks alot. It works wonderfull now :)

And btw yes the scaling problem was also an older problem. Maybe you remember. I finally changed it now.

I tested the last controller. There are minor problems which i think i can solve with changing some settings. But the SimpleCharacterController works fine now and is configured correct. So for the moment: Never touch a running system :D

bests,
J2T
Post Reply