Godot Version
4.2.2
Question
`so the player has 3 health. when the player collides with the enemy, he gets damaged by the enemy and maybe damaged another time instantly. so i just want to implement a simple cooldown that lasts around 1.5 seconds’
4.2.2
`so the player has 3 health. when the player collides with the enemy, he gets damaged by the enemy and maybe damaged another time instantly. so i just want to implement a simple cooldown that lasts around 1.5 seconds’
As said @slartibartfast , use a timer.
When the player is hit :
When timer ends :
how do you make a player “invincible” because when i disable the collision the player just falls off the map
and sorry if i sound dumb or anything, its my 3rd day in programming and thank you for your precious time
You can do it in different ways:
For example, you can create a flag can_be_hit and in your hit function, check if the player can be hit before computing the damage, when the timer times out it set the flag back to true and the next hit is accounted for.
You can set different collision layers for different use cases, so the hit be done on layer 2 and you disable only that layer: Physics introduction — Godot Engine (stable) documentation in English
See what works better for you
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.