This question was
closed Aug 07, 2016 at 10:54 PM by
Vesol.
Question by
Vesol · Aug 04, 2016 at 06:15 PM ·
rotationquaternionrotate
How to smoothly rotate the object?
The object is rotated using the buttons
if (touch.position.x < middle && touch.phase == TouchPhase.Stationary)
{
ballGameObject.transform.Translate(new Vector2(-1f, 0f) * 20f * Time.deltaTime);
groundGameObject.transform.Rotate(new Vector3(0f, 0f, 1f) * 20f * Time.deltaTime);
}
if (touch.position.x > middle && touch.phase == TouchPhase.Stationary)
{
ballGameObject.transform.Translate(new Vector2(1f, 0f) * 20f * Time.deltaTime);
groundGameObject.transform.Rotate(new Vector3(0f, 0f, -1f) * 20f * Time.deltaTime);
}
Suppose I have an object is rotated by 30 degrees. How smoothly poverut it to 0 degree?
Comment
Answer by eitanwass · Aug 04, 2016 at 06:27 PM
You could use Lerp, Or LookAt But in your case i'd recommend Lerp.
Answer by Vesol · Aug 04, 2016 at 08:25 PM
With this code I object rotates instantly.
groundGameObject.transform.rotation = Quaternion.Lerp(transform.rotation, transform.rotation, Time.deltaTime * 1);
Many have tried and does not work.