click to play button
click to replay button
slider_variable_update
X
00:00 / 00:00
CC
In this screencast we are going to show you a tip
about using sliders with variable intervals.
The idea is that we have a variable distance here
and we want to animate a point moving from 0 to
the end of that distance.
So we first need a slider for distance and we will
make it an integer slider.
We will call it d and we will have it go to 6
because that is basically what I have here. Apply.
Move it over to 4.
And now we are just going to make a line
segment from 0 to d so that we can see where
our point is moving.
Segment of given length. Click on (0,0). Tell it we
want it to be a length of d. OK.
Now, we want a point that moves along from 0 to
4. So we need another slider. We will call it t.
And it goes now from 0 – and this is the new part
– this is now going to be variable d. Apply.
Now let us make our movable point. So we come
down in the input bar. Let us call it P=(t,0) (hit
Enter).
So we should have P go from 0 to 4 and back
again. Let us see. Animation on. And it does.
Okay. And we notice that t goes from 0 to 4.
Now let us suppose is going and we decide to
update d. We really cannot tell whether it is
updated or not updated here.
So a good plan might be that when we update the
variable on which our slider depends that our
slider reverts to 0.
Very easy to do. Right-click on the slider that you
are going to update. Go to Object properties. Click
on the Scripting tab. Don’t be afraid.
And then type it what you want. So when I
update this slider I want t=0. Now this is critical.
You have to click OK. And then Close.
Otherwise it does not work. So now if I update
this, t will go to 0. If I am animating it and I decide
to update it, t will go to 0.
So this is a nice way to make sure that your
slider reverts to 0 when you update your
variable.