How to make a regeneration system?

Godot Version

Godot 4.2.1.stable


How do I create a regeneration system in Godot? I’m learning how to code and I was wanting to make a system where you can do a super jump if your “rage” is at 100, how do I make a system where every 0.1 seconds or so it regens 1 rage?

func _process(delta):

This this:

extends Node

var diff = 0.0
var rage = 0

func _process(delta):
	diff += delta
	if diff >= 0.1:
		rage += 1
		diff = 0
1 Like

Maybe I messed something up on my end but this code doesn’t seem to be working, even when its copied line for line.

Be sure you have:

var diff = 0.0

The above makes diff floating point.

and not

var diff = 0

That makes diff an integer, and will never accumulate past zero.

I would mark both as the solution because the original was the full answer but this made it work so I just marked him because it was the original answer, thank you.