- Home /
Gradually reduce speed
Basically I am working on following application of android version Party Games: Drinking Wheel and American Roulette
For this I want to rotate wheel and want to stop wheel at specific point. But I want this with gradually decreasing speed. For example at start I have speed of 10 then at stop time it at 0. So wheel stop smoothly.
At present I have viewed other post and implemented rotation of wheel but it didn't smooth, it stops on the spot. I can't able to figure out whether I have to use physics for this or not?
I want some help in this. Thanks for your time.
you can control speed in $$anonymous$$athf.Lerp I think.
Answer by Issah · Aug 07, 2014 at 08:10 AM
Hi,
Yes Mayank is right, you can try something like :
currentSpeed = Mathf.Lerp(initialSpeed, finalSpeed, Time.deltaTime);
Thanks! I understand your point. For this I will reply you shortly. If I want to write my own Lerp like function then it integrate what coding in that??
Im not sure to understand my english is pretty bad. I think you want to code your own Lerp or understand how it works ? Lerp mean linear interpolation : http://en.wikipedia.org/wiki/Linear_interpolation
If you want a regular curve its an affine function like ax + b
I think you want a curve like a log, fast at start and slower with time, and when you'r close to the wanted value you stop your Roulette (cause Log never reach the final value) :
http://en.wikipedia.org/wiki/Logarithm
$$anonymous$$athf is an unity class which provide manny function to calcultate this type of curve :
http://docs.unity3d.com/ScriptReference/30_search.html?q=mathf
I hope it will help.
I have asked question related to this topic so you have to paste your comment as answer there.
$$anonymous$$ayank allready answer :
public static float Lerp (float from, float to, float t)
{
return from + (to - from) * $$anonymous$$athf.Clamp01 (t);
}
Linear function is ax + b.
In this example :
from = b;
(to-from) = a;
$$anonymous$$athf.Clamp01 (t) = x;
$$anonymous$$y answer is badest than $$anonymous$$ayank answer
EDIT : i will past my answer i have find some new information for you ;)
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Rotate GameObject using Coroutine 2 Answers
Unity 2d animation acting strange 0 Answers
acceleration and eulerAngle problem 0 Answers