Why does the character controller get stuck?

Hi.

I am currently writing code for our character controller for our upcoming game Pirates Of New Horizons

We stumbled upon this issue (pun intended, you’ll get it), where the character controller gets stuck if he walks up a ramp and there is an edge there.

You can see the issue in a very simple scene we created with the standard character motor: Click here to see for yourself

All you need to do is press w and watch as the character controller slides along the wall of the upwards ramp for a tiny bit before he comes to a complete halt and is stuck there.

If you want to download the scene and check it for yourself within unity, then you can download press w get stuck

The funny thing is, this did not happen with Unity 2.6, but was inserted with the unity 3.0 release.

I have tried a lot of different solutions to fix this, but none of them have proved to overcome this issue, so I turn to you. Please help.

Well, I tried several tricks - probably many of them very similar to the ones you’ve tried. The only one which proved to work without collateral effects was the most stupid one: it just toggles the Step Offset between stepHeight and stepHeight+deltaStep at each frame, which fools the wall/step limit and allows the character to climb the edge at which it would otherwise get stuck (doesn’t work if toggled only during collision). As a general rule, deltaStep must be somewhat greater than stepHeight for this to work.

This is a really dirty trick, for sure, but hope it can help you - and if you find any more elegant solution, please share it with us!

var character: CharacterController;
var stepHeight = 0.1;
var deltaStep = 0.3;
private var toggle = false;

function Start(){
	character = GetComponent(CharacterController);
}

function Update(){
	character.stepOffset = stepHeight + (toggle? 0 :  deltaStep);
	toggle = !toggle;
}