Hi ,
thanks for sharing your solution.
Using the velocity for falldamage is a pretty awesome idea.
For now I will use another way because I’m not interested in doing everything physically correct:
I take the difference between the characters Z-position when he starts jumping and his Z-position when he hits the Ground.
Then I use it as a X-value in a linear funktion to apply damage: f(x) = a(x-b)
Code:
if (GetCharacterMovement()->MovementMode == EMovementMode::MOVE_Falling && ! bFalling) // bFalling is for checking if the character just started jumping
{
FallstartZposition = this->GetActorLocation().Z; // Z-value for startposition
}
if (GetCharacterMovement()->MovementMode != EMovementMode::MOVE_Falling && bFalling)
{
FallendZposition = this->GetActorLocation().Z; // Z-value for endposition
if (0.2*(FallstartZposition - FallendZposition - (FallDamageResistenz * 800)) > 0) // Check if value will be bigger than 0
{
HealthDecrease = HealthDecrease + ((0.2*(FallstartZposition - FallendZposition - (FallDamageResistenz * 800))) / 100 * MaxHealth); // Damagefunction
}
}
bFalling = GetCharacterMovement()->MovementMode == EMovementMode::MOVE_Falling;
I’m using “FallDamageResistenz” so I can controll the falldistance until the character gets damage.
It’s probably not perfect because I’m very new to programming but it works for me:D