IsGrounded causing problems.

I have looked at the other questions but what they recommend doesnt seem to work. This code is the physics part of my character movement. It just randomly jumps and I put a debug log code into it to monitor the variables and it seems half the time im grounded it thinks im ungrounded? Oh btw, cc is my charecter controller and anim is the animation controller. When I say it randomly jumps I mean the jump animation is being triggered but I’m on the ground.
using UnityEngine;
using System.Collections;

public class Newmove : MonoBehaviour {
	// This component is only enabled for "my player" 
	public float speed = 10f;
	public float jumpSpeed = 6f;

	Vector3 direction =;
	float   verticalVelocity = 0;
	CharacterController cc;
	Animator anim;
	// Use this for initialization
	void Start () {
		cc = GetComponent<CharacterController>();
		anim = GetComponent<Animator>();
	// Update is called once per frame
	void Update () {
		direction = transform.rotation * new Vector3( Input.GetAxis("Horizontal") , 0, Input.GetAxis("Vertical") );

		if(direction.magnitude > 1f) {
			direction = direction.normalized;
		anim.SetFloat("Speed", direction.magnitude);

		if(cc.isGrounded && Input.GetButton("Jump")) {
			verticalVelocity = jumpSpeed;

	void FixedUpdate () {

		Vector3 dist = direction * speed * Time.deltaTime;
		if(cc.isGrounded && verticalVelocity < 0) {

			anim.SetBool("Jumping", false);
			verticalVelocity = Physics.gravity.y * Time.deltaTime;
		else {

			if(Mathf.Abs(verticalVelocity) > jumpSpeed*0.75f) {
				anim.SetBool("Jumping", true);
			verticalVelocity += Physics.gravity.y * Time.deltaTime;

		dist.y = verticalVelocity * Time.deltaTime;

		cc.Move( dist );

I think you have some errors in your logic. When the character is grounded, vertical velocity should be equal to zero. Do you want to require that the character is grounded before you jump? Make sure the variable direction is normalized.

There’s nothing wrong with the jump animation. It’s that the jump animations is being triggered randomly. What I meant that the physics side isn’t jumping with the random jump animations. Meaning the part of the code where it sets anim.SetBool(True) must be broken in some way. The state machine is fine also. What I need to know is why the charecter controller thinks it is grounded half the time and ungrounded the other?