How to make a stopwatch in godot?

glancedUpglancedUp Posts: 46Member

Hi again :)

I am making a game where I want to time myself doing certain thing. The time would be the score in this game. Therefore I need to make a stopwatch to time myself.

How do one make an effective / usable stopwatch in Godot?

As always,
Thanks in advance :)

Best Answer

  • kow__kow__ Posts: 24
    Accepted Answer

    Create a node, then attach a script and:
    -Create a time variable, set it to 0.0;
    -Put time += delta in _process();
    -Create a get_time() function, and put return time in it.

    And with that you should have finished. Then just call get_time() if you want to get the time.

    If you want, you can also add a reset_time function that sets the time to zero.

Answers

  • kow__kow__ Posts: 24Member
    Accepted Answer

    Create a node, then attach a script and:
    -Create a time variable, set it to 0.0;
    -Put time += delta in _process();
    -Create a get_time() function, and put return time in it.

    And with that you should have finished. Then just call get_time() if you want to get the time.

    If you want, you can also add a reset_time function that sets the time to zero.

  • glancedUpglancedUp Posts: 46Member

    Thank you very much kow_!! :D

Sign In or Register to comment.