jeudi 4 juin 2020

JAVA Weird bug that gets fixed with "System.out.println("TEXT");" [duplicate]

I have my deltaTime loop ,in a MultiThreading program, that returns this void:

public static void update(double deltaTime){
//      System.out.println("I am here");
        if(Key.W){
            Player.y-=deltaTime*Player.speed;System.out.println("Holding W | Adding : "+(deltaTime*Player.speed));
        }
}

The program is simple , to check if 'W' is hold and then ,if true, change players Y coordinates.

When I hold W , i get visual feedback that I am holding it , but the code from if statement (Key.W is TRUE for sure) is not being executed.

But it is not working unless i remove '//' from second line of code :

public static void update(double deltaTime){
        System.out.println("I am here");
        if(Key.W){
            Player.y-=deltaTime*Player.speed;System.out.println("Holding W | Adding : "+(deltaTime*Player.speed));
        }
}

Now it is working ... I get no errors in both scenarios , everything else is working :/

What can be the case of this weird bug ?

Aucun commentaire:

Enregistrer un commentaire