Help with simple maths

Hello!

I have a vector length float value that is updated on tick, and I’d like to make length values 0.1 to 15 into 0 to 1 (ignoring what’s out of that range), for then increase another value as vector length decreases (and vice versa). So length values end up being 0.1=1 and 15=0. I’m pretty sure there’s functions to do so easily but I can’t wrap my head around it so far.

Hints will be appreciated :slight_smile:
Thanks in advance

A = in Range A
B = in Range B
C = Out Range A
D = Out Range B
X = Clamp( VectorLength, 0.1 , 15)

Q = ( (X - A) * (D - C) ) / (B - A) + C

… or Map Range Clamped | Unreal Engine Documentation

2 Likes

This did perfectly the trick, with inverting C and D to get the increasing value as length decrease. Thank you!