mardi 4 avril 2017

Does someone know what's wrong in my if statement in C# Unity3D?

I want to change the int speed value, but it doesn't work. Can someone help me? If you too have too few information, pls ask me. This is my code:

    if (Input.GetKeyDown (KeyCode.W)) {
        sprint1 = true;
    } else if (Input.GetKeyUp(KeyCode.W)){
        sprint1 = false;
    } 
    if (Input.GetKeyDown(KeyCode.LeftShift)){
        sprint2 = true;
    } else if (Input.GetKeyUp(KeyCode.LeftShift)){
        sprint2 = false;
    }
     if (sprint2 == false && Input.GetKeyUp(KeyCode.W) && Input.GetKeyUp(KeyCode.A) && Input.GetKeyUp(KeyCode.S) && Input.GetKeyUp(KeyCode.D)){
        speed = 0;
    } if (sprint2==false && (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D))){

        speed = 4;

    }if (sprint1 == true && sprint2 == true && Scoped==true) {
        speed = 8;
    }

Aucun commentaire:

Enregistrer un commentaire