When the player is in the hitbox of an enemy and they stay there, I want the player to take damage every 1.5 seconds or so. When I run a bool thru _process and connect it to on_enter and on_exit signals, the player immediately dies (A timer between hits doesn't seem to work, _process is too fast). When I just make an on_enter to take damage, the player only takes one chunk of damage and nothing else. How should I go by making this?

    jenkem_enoshima When I run a bool thru _process and connect it to on_enter and on_exit signals, the player immediately dies

    Explain that in more detail.


    An alternative to using a Timer is to keep track of the elapsed time (in _process or _physics_process).

    const TIME_INTERVAL: int = 1500 # msec
    ...
    var saved_time: int = OS.get_ticks_msec()
    ...
    if OS.get_ticks_msec() - saved_time > TIME_INTERVAL:
        # do something
        ...
        saved_time = OS.get_ticks_msec()

      I'd probably just try using a timer and enter/exit signals to toggle a boolean value(lets call it do_damage). Then on timer timeout check if do_damage is true.

      4 months later

      DaveTheCoder i want to make a damage system where if the player enters a hitbox that damages them, they are hit but after they're hit, are invincible for a second to get their bearings. If that second is up and they are still in the hitbox, they will take another hit.

      Did you understand the above replies by me and Megalomaniak?