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.
March 21, 2021, 2:09pm
You could do a reciprocal function. A number (for example 1) divided by the magnitude.
March 21, 2021, 2:11pm
You can use startMagnitude - currentMagnitude, the value will increase as they get closer
@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.
Thanks for the explanation for measuring the distance between two points, but if you watched the gyazo and I don’t blame you please don’t use gyazo it doesn’t embed into the dev forum share x is better
@Charl_iey has already measured the distance towards the goal.
The question is making a value that goes 0-1 rather than the distance value which goes 1(some distance)-0.
And I believe the official term for it is linear curve fitting:
You plot the points and numbers you want and connect them in…
March 21, 2021, 2:17pm
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.