Hi
I am currently working on a 3D slider that will be placed inside the game world itself.
I am wondering if there were a method similar to
public static float InverseLerp(float a, float b, float value);
but for vectors specifically for Vector3. I have sort of a work around. The sliders that i currently have placed are all working parallel the world unity axis, Vector.up, right and forward.
The solution that i have right now for world axis sliders output the slider value like so:
public float SliderOutput{
get{
switch (RotationAxisChoice) {
case Axis.X:
return _sliderOutput = Mathf.InverseLerp(_lowerLimit.x, _opperLimit.x, _currentSlidePos.x);
case Axis.Y:
return _sliderOutput = Mathf.InverseLerp(_lowerLimit.y, _opperLimit.y, _currentSlidePos.y);
case Axis.Z:
return _sliderOutput = Mathf.InverseLerp(_lowerLimit.z, _opperLimit.z, _currentSlidePos.z);
}
return 0f;
}
}
this should work for the special case that the slider is perfectly aligned with the world axis, but i would like to do a generic solution that can have the slider orientated in any direction. And also get rid of the switch statement