I have this function called start(Delta) in which a variable "is_active" has to return true, I have a timer system like this: timer += Delta. I want to make a function called end() executed when a certain time passes in which is_active becomes false. I want the start function to call a function "Hurt_box.create_hit_effect()" but I want it to be executed only once, not all the time (since "start()" works the same as a procces, except that I can call it whenever I want ) and also, when you call the start() function again once end() has been executed, the hurtbox function can be called again.
This is what I tried to do:
var hurt_timer = 0.0
var one_time_effect = false
func start(Delta):
`if one_time == false:`
`Hurt_box.create_hit_effect()`
`is_active = true`
`one_time = true`
`if is_active:`
`hurt_timer += Delta`
`if hurt_timer >= 0.2:`
`hurt_timer = 0.0`
`one_time_effect = false`
`end()`
`Hit_box.collision_shape_2d.disabled = true`
func end():
`emit_signal("end_state")`
`is_active = false`
`one_time = false`
` :
If you need more information, you can ask, I would be very grateful if someone could help me :)