Speed of the script

I can’t understand why the Speed stay very fast

Thank you for your attention

    public float speed = 1.0f;

    float bas = 0;
    // Start is called before the first frame update
    void Start()

    // Update is called once per frame
    void Update()
        if (Input.GetKeyDown("s") || Time.time - bas >= 1)

        transform.position += new Vector3(0, -1, 0);

        if (!DansGrille())

            transform.position += new Vector3(0, 1, 0);

            enabled = false;


            bas = Time.time;
        } }


Probably because Time.time - bas >= 1 is always true (and will happen every frame), until bas = Time.time if !DansGrille().

I’m not sure what you are trying to do, but you should think when you want to enter the if statement, and if you want to to repeat it at an interval it can be done simpler with Time.deltaTime but it is possible with Time.time also. And it would be better to just set transform.position once or not at all then to set it twice.

Try using Time.deltaTime

i think just insert one more if statement of if(Input.GetKeyUp(“s”)) and make your speed default inside it…