Search Unity

How to level up attack and defence in game?

Discussion in 'Game Design' started by Xhitman, Aug 20, 2018.

  1. Xhitman

    Xhitman

    Joined:
    Oct 30, 2015
    Posts:
    452
    In my game, player can increase attack or defence when level up. If player select defence increase each time, finally player defence will be larger than monster attack.

    So, damage = attack - defence do not work, player take no damage in game is just a bug.

    I want the damage increase as an exponential function, y = a ln (x) + b, but I don't know how to deal with defence to avoid "take no damage" situation.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Instead of subtracting defense from attack, how about have defense reduce damage as a percentage? Then you can cap defense at a high percentage so as to never reduce by 100%. Maybe cap at 0.9 or 0.99 or so.

    Code (csharp):
    1. float damage = attack * (1f - defense);