HUD Text Overwriting

Hi, first the method :stuck_out_tongue:

[java] if (up){

        waterValue = waterValue - 1;
        foodValue = foodValue - 1;
        if (foodValue == 1 && up)
        if (waterValue == 1 && up)
        foodString = String.valueOf(foodValue);
        waterString = String.valueOf(waterValue);
        /** Write text on the screen (HUD) */
        guiFont = assetManager.loadFont("Interface/Fonts/StatsNew.fnt");
        BitmapText food = new BitmapText(guiFont, false);
        food.setText(foodString + "%");
        food.setLocalTranslation(90, settings.getHeight() - food.getLineHeight(), 0);
        BitmapText water = new BitmapText(guiFont, false);
        water.setText(waterString + "%");
        water.setLocalTranslation(90, settings.getHeight() - water.getLineHeight() * 2, 0);

       // rootNode.attachChild(pivot);

I m not sure if anyone see it, i simply want that, if i press and/or hold “W” (to run) the food and the water should go down and that shuld be written in the text ("water.setText(waterString + “%”); ) my posted method dont work really well but i cant think of a better one
ty for helping

You don’t really say what “not working” is in this case but if this is the code that updates the text that’s not what it’s doing. It’s creating new text every time.

If this is not the code that’s updating the text then I don’t know how we’re supposed to help as we haven’t really been given any information.

You haven’t shown enough of your code for us to debug it. Have you tried stepping through it in the debugger?

The main question is how i can make a Text (like with the HUDText tool on the side) but which updates if i attach it new or change the variable.
If i use the code i posted it ll keep the old text means i ll have a 99% and over it a 98-1. and i want that it writes 99% and if it becomes 98 it should pdate to 98 and not print both

Then change the bitmap text you already created instead of creating a new one every time.

If BitmapText was a whiteboard you are creating a new whiteboard every frame instead of just erasing the old text and writing new text.