Boss hitting issue

godot 4

Boss health
I have this code for hitting the boss
elif area.has_method(“isboss”):
if hittingBoss == false:
hittingBoss = true
Inventory.bossHealth -= 1
await get_tree().create_timer(0.4).timeout
hittingBoss = false
the issue is it hits the boss each frame so it does way to much damage
thanks for any help in advance

is hittingBoss declared in the same function? I feel like that should be a variable on the boss script.

Use the </> button on a new line to paste code, it will make three ticks like so

```
type or paste code here
```

1 Like

Instead of running the code every frame (you don’t show where the code is run but I assume it’s in a process function) start running it once the player enters the boss’s hitbox and run it as often as you want, and then stop running it when the player leaves the hitbox.