Flashlight intensity, getting values to scale

alrighty, what I’ve got right now is a flashlight that will fade out to a minimum value when the Battery Current float is <= 25% of the maximum, this works fine and is okay, but what I’m trying to do is scale the light based on that last 25%, essentially I would like to treat Battery Current at 25% as 2500 (which is the maximum brightness), and Battery Current at 0 as 250 (which is still visible but dim) those two numbers I’ve set in the clamp.

The reason I would like to set it like that is so when I scale up or down the max value, that 25% will get bigger and smaller, which in turn should fade the light out quicker or slower. right now if I were to decrease the maximum, the light would still fade even though you had 0 power, and if I were to increase the maximum it would fade before the battery was out of power.

What I did try was adding that A%B node, but that seemed to just instantly set it to the minimum as soon as the battery current was at 25%

I tried some other math stuff, but because I’m not the best at maths it didn’t work (because I didn’t know what I was working with haha)

I tried something like this (clamp(input, min_input, max_input) - min_input) / (max_input - min_input) as the input for (input * (max_output - min_output) + min_output)

but that too didn’t work.

Any help would be much appreciated.

only the bit in red is what I’m working with, and the bit in purple is what is handling that change…

Cheers.

Have you tried using a Linear Interpoloate? It takes in values A and B and lerps (blends) between them based on an alpha. Now, that alpha is going to have to be 0-1 based, so you’d simply divide your battery power by its max power. If you then multiply that result by 4, then the value won’t dip below 1 until it’s 25% expended. Then you’d just set your A and B values to your max and min, respectively.

Remember, with a lerp, Alpha of 0 returns A, Alpha of 1 returns B.

Thanks mate, I didn’t know what lerp was used for so I ignored it, such a simple fix.

Here is what it looks like now.