- Home /
Rotate Ball with high speed rotation to slow speed
For my roulette game, I want to rotate ball around centre with higher speed then slowly decrease its speed to 0. At start position for example ball start with speed 100 then at stop position its speed be 0.
I have written following code as per my understanding but going some what wrong in that even rotation cant seem correct one.
IEnumerator doSpin (float time, float maxAngle)
{
float timer = 0.0f;
float startAngle = transform.eulerAngles.z;
while (timer < time) {
float angle = ac.Evaluate (timer / time) * maxAngle;
transform.localRotation = Quaternion.Euler (new Vector3 (0f, 0f, angle + startAngle));
timer += Time.deltaTime;
yield return new WaitForSeconds(0.000001f);
}
transform.localRotation = Quaternion.Euler (new Vector3 (0f, 0f, maxAngle + startAngle));
wheelController.BallStopAtNumber ();
}
Using above code ball is moving with same speed, I want changes in speed as per my above description.
Please some one give me suggestion over here. I am available to reply you anytime if you not understand my question.
Anybody has suggestion or example for this? Please give me some help.
Answer by siddharth3322 · Oct 14, 2015 at 09:03 AM
I got my above question's answer myself only. I writing here for other members usage because they definitely come across in same condition.
Basically I am using Animation Curve for rotation of ball. Then it is solution my question. I change shape of Animation Curve to curve line from flat line. Following image gives you more idea about this.
Answer by alok-kr-029 · Oct 09, 2015 at 10:11 AM
Just a suggestion cant you use coroutins to slow down the speed
Lets give me one try for this. Reply back to you with some sort of result. Thanks for your quick reply.
Your answer
Follow this Question
Related Questions
Lerp 180 degrees while holding B and lerp back 180 degrees when let go of B. 2 Answers
LookRotation Vector3 is Zero, Yet Slerp Still Rotates? 2 Answers
How can I instantiate a gameobject facing another gameobject 2D? 0 Answers
Quaternion slerp t parameter never reaches 1 1 Answer
Rotation direction in coroutine 2 Answers