I have a compiler error that i can't fix

When i start my game Unity sais that there are compiler errors that i have to fix first. I searched in my code and i think i located the place where the errer is.
this is the whole code:

using UnityEngine;
using System.Collections;

public class Playermovement : MonoBehaviour {
	public Animator anim;
	public int verticalMovement;
	public bool isWalking;
	public bool onGround;
	public float fallSpeed;
	// Use this for initialization
	void Start () {
		isWalking = false;
		verticalMovement = 0;
		onGround = true;
		fallSpeed = 0.03f;
	}
	
	// Update is called once per frame
	void Update () {
	//if you are on the ground and press space verticalmovement will we be places on 1.
		if (Input.GetKeyDown(KeyCode.Space) == true && onGround == true) 
		{
			verticalMovement = 1;
				onGround = false;
			}
		else
		{

			if (onGround == false && verticalMovement > 0)
			{

			verticalMovement -= fallSpeed;
				

				if (verticalMovement < 0)
				{
					verticalMovement = 0;
					onGround = true;
				}
			}
		}
		
		// Update the animator variables
		anim.SetFloat("VerticalMovement", verticalMovement);
		anim.SetBool("OnGround", onGround);
     

	
	}



}

and this is where i think the error is:

else
		{

			if (onGround == false && verticalMovement > 0)
			{

			verticalMovement -= fallSpeed;
				

				if (verticalMovement < 0)
				{
					verticalMovement = 0;
					onGround = true;
				}
			}
		}

I hope you can help me :).

First of all it’s not good practice to reduce the value of an int using a float, as in line 32:

verticalMovement -= fallSpeed;
verticalMovement is an int
fallSpeed is a float

Then in line 44 you call the SetFloat function of Animator on an int, which seems to be the source of the error:

anim.SetFloat("VerticalMovement", verticalMovement);

//You should use:

anim.SetInteger("VerticalMovement", verticalMovement);

Hi @Thijsx7, I’m glad I helped. Please mark my answer as “answered” (green “check mark” icon below the down-vote icon).