So, here’s the score. A system I’ve been tinkering with is about making damage fall off based on the distance.
Though I tried using a direct linear falloff equation, that’s not quite what I am needing.
So, after some digging (and being reminded that math is probably one of the more crucial subjects in high-school if you want to do game-development) I’ve figured out that the nice, gentle curve I am looking for is to be found in a quadratic equation.
So, with the help of a little web-widget I found the curve
Ax^2 + Bx + C = 0
Where A is -.9, B is 0 and C is 1. This would give me a nice curve where I can have the tail end of the explosion still do damage.
Thing is, I am at a loss as to how to factor this down into a format that I can use to calculate Y where X is the distance.
If it helps, it’d be in terms of percentages and multipliers. So, this curve would be the template to use to calculate the multiplier to apply against the total damage to be dealt. That also frees be up to feeding it the range as a variable itself (well, i’d have to reduce it down but that kind of math I can handle.) So, therefore if the total range is 25 units as radius and the maximum damage is 75, I can easily just take the distance of the object, calculate that against the maximum range to get the percentage (divided by 100… or just not multiplying it BY 100 at the tail end of those calculations to figure that bit out.) Then I can take that value and filter it through this equation so that if the distance is X then it will result in Y which will be the multiplier to use for the total damage.
So, therefore, assuming distance is 25 units away, total range is 50 units, I’m left with a value of 0.5 that I can then use on the X to get Y which will be what I multiply the total damage by in order to get the “reduced falloff” damage value.
So, I’ve been able to figure out the equation I’ll need and the right settings/values to use to define it… but factoring it down into a format that I can use in this system is where I’m having a bit of trouble here.
Anyone with a math-mind willing to help out here?