- Home /
Character Controlling grinding along any non-flat Terrain
Hey all,
Working on a 3rd person controller that is using Unity's built-in Character Controller.
As a test area, I simply made a small terrain, and made random bumps, plateaus, etc, in order to test out the controls.
However, on anything that isn't the default 0 height flat terrain, even completely flat plateaus, my character almost constantly slowly grinds along the ground, happening more so when I'm going left or right.
I'm using the built-in Character Controller functionality, so forward movement is as simple as
controller.Move(transform.forward * speed * Time.deltaTime);
Anyone had this issue before? No problems falling through the world, but this grinding will prevent any use of this in game.
I should also mention the height is 1, radius is 0.5, slope limit is 45, step offset is 0.3, skin width is 0.08, and min move distance is 0.
Thanks for any help!
can you define "grinds along the ground"? Is this not the behavior you were expecting?
It shudders and jitters horribly, slowing down the movement significantly usually.
This, among other things, is why I never use the inbuilt 'CharacterController' component. They sound like a good idea, simplifying your control scripting, but in reality they tend to cause more trouble than they're worth. Either use a rigidbody, or write your own custom controller using raycasts and a collider.
I dunno, I'm having no problems besides this. Rigidbodies aren't fun to make controllers out of, and I'd rather not deal with having to handle collisions and such on my own. :\
Does it stop if you remove the check for grounded
? (replace for now with if(true)
?) What other checks are in your script?
The standard script only allows you to move when "grounded". Depending on terrain, I've had it move, then next frame have to "fall" 0.001
meters to be grounded again. $$anonymous$$ostly happens to me when walking a downward slope.
Answer by Owen-Reynolds · Mar 27, 2012 at 02:43 PM
One fix (have done it, but lost the code) for "not always grounded over uneven terrain" is to toss in an extra check: "if you were grounded 0.05 seconds ago, didn't just jump." Something like:
float groundedUntil=0.0f; // will be a game time
// movement code:
if(Time.time<groundedUntil) { // replaces grounded check
if( jumping ) {
groundedUntil=0; // "turn off" the grace period -- we aren't grounded
...
}
}
grounded = .....
if(grounded) groundedUntil=Time.time+0.05f;
What I ended up doing was essentially a jump timer, but I also added in constant downward gravity to the walking phase as well. Otherwise, I ended up with this "fall every 0.X seconds when the jump phase activates" kinda thing. This is smooth and sexy.
Thanks for the help, again. :)
Your answer
Follow this Question
Related Questions
Riding a second character controlled object 2 Answers
Randomly some prefab instances have Character controller misaligned 0 Answers
Motion over sloped terrain 0 Answers
Character controller / terrain collider - am I misunderstanding these? 1 Answer
Charactercontroller jittering while jumping into wall 0 Answers