@Azedaxen , I just met the necessity to implement the damage based on downward velocity instead of time spent in the air. =)
When I jump off the top of the tree trunk, and then land on the same tree trunk, but nearer the ground (basically, I land on a flight zone) and then I peacefully get off the tree , when I touch the ground, the player receives damage from the time spent in the air, a few seconds ago, when he is not even falling.
It turns out that if I stay on the base of the trunk for a minute, then, when I touch the ground, I will receive damage from time spent in the air a minute ago. It is weird xD
Even if this solution works very well, in order to get rid of this bug, I have to modify it.
Do you guys know how to record the downward velocity when the player touches the ground?
I tried a modification of the previous solution:
if is_on_floor():
if (in_air_time > 0):
print(velocity.y)
in_air_time = 0
elif !flying:
in_air_time += delta
but this solution measures the velocity when the player is already on the ground. The velocity is, of course, 0. ))
I have to record the velocity just before landing.