Hello Devs, I'd like to be able to keep track of my slider values for instance current value and previous value and then I'd like to perform action based on if currentvalue is greater or less then the previous value, how do i model this?
Hello, how are you doing guys, the problem here is i want to keep track of slider values the currentvalue when the user interacts with the slider, and the value before interacting with it, i want it to be done in update or fixed update because i'm controlling rotation of my plane on x-axis with slider,and mapping the value of slider with verticle axis,
void FixedUpdate()
{
//sliderpreviousvalue=throtle.value;
if (rotateonslider) {
Debug.Log ("Currentvalue :" + currentslidervalue + " prevvalue: " + sliderpreviousvalue);
if (currentslidervalue> sliderpreviousvalue && sliderpreviousvalue > min && sliderpreviousvalue < 0) {
vertical = currentslidervalue;
}
if (currentslidervalue < sliderpreviousvalue && sliderpreviousvalue <= max && sliderpreviousvalue <max) {
vertical = currentslidervalue;
}
transform.Rotate (vertical,0f, -horizontal);
}
}
the sliderpreviousvalue is saved in pointerup event of the slider
public void rotateonsliderfunc()
{
rotateonslider = false;
sliderpreviousvalue = throtle.value;
}
and the currentslidervalue is saved in onvaluechangedevent of the slider
public void ReduceForce(float v)
{
rotateonslider = true;
currentslidervalue = v;
}
yet the values returned are ambigous, sometimes same, and sometime the previous value is zero if the user doesn't lift off the finger from slider. how can i get it done? basically what i want is i have a range of min and max values of the slider, from zero to min i want negative rotation on x-axis, and from zero to max i want positive rotation, but i would also like to be able to rotate accordingly based on whether slider is going from min to max, or from max to min.
Your answer
Follow this Question
Related Questions
How to decrease a Slider value by time? 1 Answer
Scripting problem, sliders, monobehaviour 1 Answer
Rotate character 0 Answers
Slider problem 1 Answer