Deplacement vertical

Je voudrais créer un script pour que mon personnage se déplace du haut de la scène vers le bas. Et que quand son axe vertical est égale a une certaine donné, mon personnage monte et quand il est égale a une autre donnée, mon personnage descend. J’ai commencé mon script comme ceci :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AutoMouvUp : MonoBehaviour {
private float y = Input.GetAxis("Vertical");
// Use this for initialization
void Start () {

}

void Update () {
if (y = -5.9)
{
transform.Translate(Vector2.up * 4f * Time.deltaTime);
}
if (y = 6.17)
transform.Translate(Vector2.down * 4f * Time.deltaTime);
}
}

Le problème est que la console m’affiche l’erreur suivante :

Assets/Standard Assets/2D/Scripts/AutoMouvUp.cs(14,18): error CS0664: Literal of type double cannot be implicitly converted to type float'. Add suffix f’ to create a literal of this type

Je ne comprends pas, car très nul en programmation et je ne trouve pas sur Google donc si quelqu’un pouvait m’aider.

use == for compare

if (y == -5.9)

        {

            transform.Translate(Vector2.up * 4f * Time.deltaTime);

        }

        if (y == 6.17)

greater/lower compare can be better in this case because the y value can be lower as -5.9 or bigger as 6.27 and your script is only checking if the y is equal the searched value:

if (y <= -5.9)

        {

            transform.Translate(Vector2.up * 4f * Time.deltaTime);

        }

        if (y >= 6.17)