Calculate tween duration based on variable speed and fixed distance

Hi,

Wondering if anyone could help here. I need to tween a speed variable over time to reach zero, so that the speed and distance of an object to a position both converge at 0. I can calculate the distance that is to be travelled when we are creating the tween, and I know the starting speed. But I need to calculate the duration for this tween, which will be tweening the speed value itself.

Any help is appreciated.

Adam

You want to know how fast your variable will reach zero. For this you need to know initial value and decrease speed. Then divide value by speed to get duration. If decrease speed is not constant, you may use average speed in this calculation. If average speed is unknown too, then you need tween function integral. And if you unable to calculate that, then the problem is impossible to solve.
By the way when making games you usually set tween time instead of calculating this. I.e. designers said this ui animation tween must complete in 0.5 seconds, and then you calculate tween to cover required distance in 0.5 seconds. This is needed to make consistent user experience.

Thanks. Turns out this was an overly complex way of thinking about the problem, and we could do it in another way. Thank you for taking the time to respond though.