Bad visuals of in-game timer

Godot Version

4.1.1

Question

Yo I am doing livesplit alternative. Right now I do the timer scripting. Currently it is going terrible, int is glitching, float does not show zero (need 0.10, get 0.1 instead).

extends Control

var start_timer:bool = false
var time: float = 0

func _ready():
	pass # Replace with function body.

func _input(event):
	if event is InputEventKey:
		if Input.is_action_pressed("Start"):
			start_timer = true
		if Input.is_action_pressed("Stop"):
			start_timer = false

func _process(delta):
	if start_timer:
		time += abs(delta)
		$Timer/Time.set_text(str(snappedf(time, 0.01)))
		print(time)

Use str(time).pad_decimals(2) to automatically add trailing zeroes.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.