How would I invert the magnitude value?

Hello there!

I’m currently working on a horror game which will have a spirit box like item inside (similar to Phasmophobia). I have got the distance between 2 parts using .Magnitude already but the further away the part is, the bigger the value.

I don’t want this to be the case as I want the value to increase as the parts get closer.

Anyone know how to do this?
Thanks in advance.

You could do a reciprocal function. A number (for example 1) divided by the magnitude.


You can use startMagnitude - currentMagnitude, the value will increase as they get closer


Yep like @Galactiq and @Jxl_s said you can use those formulas:

To make sure you understand what you are doing its best to plot it out on desmos like in this example here which uses @Jxl_s formula which is linear.

1 Like

For clarification, my suggestion would be a rational function, whereas the suggestion made by @Jxl_s is linear. Just keep those in mind when deciding which is best for your need.

1 Like