# Smooth slider with camera

Hello everyone. I have a slider with a camera, which, like in a TV show, should ride on rails at the touch of a button. Once I pressed it, I went to the right. The second time I pressed it, I stopped. If I pressed it again , I continued moving from the moment where I stopped. If the slider has reached the end, then it has stopped itself. If I press the button again at this moment , it will start moving in the opposite direction. The problem is that I can’t make the stops smooth. Now I have made it so that everything works, but the camera does not stop smoothly. I would like to have an easy in easy out effect, the camera movement looked natural. I think that we need to do this somehow without using timelines (in which I now have a value from 0 to 1 in 2 seconds). That is, it should be some kind of line, from 0 to 1 (from the beginning of the slider to its end), and the speed of movement, which is interpolated from 0 to 1. When I press the button, the speed increases smoothly to 1 and the camera moves along the slider at the same speed, gradually increasing to 1. And so on. Help with advice, thank you.

Well, there are a bunch of ways to do that.
A posibility is create a variable “camera_speed” with values between 0 and 1. This variable is controlled by a timeline, like you did on your code, width the play and reverse to change the speed.
In a diferent function or event controlled by the tick or a set timer by function name, you can add this speed to your current position on rail. ( probably you need a multiplier modifier of the speed to adjust the real speed of the camera)
Then just control if the position off the rail has reached the end or the start to change direction, just multiplying your velociti by -1.

In the example, of course i am just changing the value of curren_position_on_rail, you need the change the real position of the camera using this value !

Thanks Micky. But your example does not work out what I need. If the button is pressed once (do not press and hold it), then the movement of the slider starts at a speed of 0 and gradually increases to 1. If the button is pressed again, the speed of the slider smoothly descends from 1 to 0. That’s what I mean.

If we were looking at the example of electrical engineering, I would say that this is how the attenuation of electricity through a capacitor works. How are the schemes for smooth ignition of LEDs implemented, for example. If you know what I mean.