+3

Velocity-Based Wall Damage

BerserkerOP_Pay2Win 2 years ago • updated 2 years ago 5

Problem: Shortly after I take damage, even if I walk voluntarily into a wall, I take extra damage.


Solution: Make the amount of wall damage depend on the speed of the player.


If the player is subject to knockback and hits a wall, they would only be damaged if they are going fast enough to get hurt. I also suggest that there be a limit on the amount of wall damage attainable, so that the wall cannot one-shot a player at reasonable health. Such a system is demonstrated in the pseudocode below.


Example:

v = player speed
x = speed for min damage
y = speed for max damage
knockback = whether or not player is knocked back

if knockback:
    if player hits wall:
        if v > x and v <= y:
            damage player with v - x
        else if v > y:
            damage player with y