grounded flag while moving downhill

Hi everyone, I’m having some trouble playing the right animation when my character is moving down a hill. With the way I have my controller set up, it looks like the character actually comes off the ground when moving down any hill, then immediately falls back onto it, which causes my grounded flags to flip back and forth like crazy. I built my controller off of one of the sample project ones, and it seems like the only thing that fixes the problem is if I crank the gravity way up. Is there a better way to do this though? Here’s what I have so far, any help is much appreciated! Thanks! :slight_smile:

function Update() {
	//get direction and speed in X-Z plane
	UpdateSmoothedMovementDirection();
	
	if(!grounded)
	{
		falling = true;
	}
	else
	{
		verticalSpeed = 0.0;
		
		// We are in jump/fall mode but just became grounded
		if (jumping || falling)
		{
			jumping = false;
			SendMessage("DidLand", SendMessageOptions.DontRequireReceiver);
			falling = false;
		}
		
		// Jump		
		if (canJump  Input.GetButton ("Jump")) 
		{
			verticalSpeed = jumpSpeed;
			jumping = true;
			SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);
		}
	}
	// Apply gravity
	verticalSpeed -= gravity * Time.deltaTime;
	
	var movement = moveDirection * moveSpeed + Vector3 (0, verticalSpeed, 0);
	movement *= Time.deltaTime;
	
	// Move the controller
	controller = GetComponent(CharacterController);
	flags = controller.Move(movement);
	grounded = (flags  CollisionFlags.CollidedBelow) != 0;
	
	isOnGround = (flags  CollisionFlags.Below) != 0;
	hasHitHead = (flags  CollisionFlags.Above) != 0;

	// Set rotation to the move direction	
	transform.rotation = Quaternion.LookRotation(moveDirection);

There actually is a hacky way you can do this:
Create another Collider under your character, a bit “extruding” from the actual boundingbox of the character, set it as a trigger, and set the Grounded =true also when THAT collider collides with something (OnTriggerenter?).
This way its collisions won’t mess up your controller since they’re not there, and you still have control on a certain portion of the space between the feet of your character and the ground.
Hope that helps.