# Character bounces/stutters down hills

I'm using Unity3D (not 4) and I'm experiencing a bit of a problem with character movement. I'm using a capsule as a First Person player with a camera attached to it. In this capsule is the stock ThirdPersonController script (with the animation parts removed). I know it's not conventional, but it's not the problem in this case.

The problem is when my character goes down hills, running or walking, it bounces down. It's as if it's going horizontally, then realising it's not grounded and then falling. It works fine going uphill but the downhill is driving me crazy.

One solution that may be possible is raycasting, I know what it is but I have no clue on how to use it.

So I figured it out by myself (gee thanks a lot, downvoter) I looked inside my ThirdPersonController script and took a look around once more. I found this:

function ApplyGravity ()
{
if (isControllable) // don't move player at all if not controllable.
{
// Apply gravity
var jumpButton = Input.GetButton("Jump");

// When we reach the apex of the jump we send out a message
if (jumping && !jumpingReachedApex && verticalSpeed <= 0.0)
{
jumpingReachedApex = true;
}

if (IsGrounded ())
verticalSpeed = 0.0;
else
verticalSpeed -= gravity * Time.deltaTime;
}
}


The key bit is verticalSpeed = 0.0;. In context, that meant "If player is touching the ground, set it's vertical velocity to 0.

What I did to solve my stuttering problem was change that value to -10.0. Now I have a character that smoothly traverses hills!

• The downvote may be due to your "Yes, I'm using a Third Person script on a First Person character. Deal with it. That's not the problem though.". That and it would help if your original question had code or example images in it to help us figure out the problem. – Tom 'Blue' Piddock Jul 21 '14 at 12:55
• Okay, but I did say I was using the 'stock' script so there is no change and I wasn't going to repost the whole thing. – Pyroglyph Jul 21 '14 at 12:58
• Images would have been good. Either way I've created an answer with my suggestion. Hope it helps. – Tom 'Blue' Piddock Jul 21 '14 at 13:04

I would suggest not setting your vertical speed to -10 as this is essentially doubling the effect of gravity which can have some serious adverse effects later on.

I would replace the collider with a spherical based one on your character:

This should help smooth out collisions and contact with the ground as opposed to a square based collider which will have the sharp edge to "bounce down" hills.

Image courtesy of iPhone & Mac Development Blog

• Thanks for the answer but I already had a capsule collider active. It wasn't helping. But I appreciate you trying to help. – Pyroglyph Jul 21 '14 at 13:56
• I assumed as you said you were using a cylinder that it had a cylindrical collider. Has this been removed? – Tom 'Blue' Piddock Jul 21 '14 at 14:03
• Sorry I did mean to say capsule originally, I mistyped. – Pyroglyph Jul 21 '14 at 14:33