Permalink
Browse files

Helper: added a couple of methods used to smoothly rotate game models.

  • Loading branch information...
1 parent 11aa4cb commit 8f2e8ff256b8438f20c4118e733c7e6de8434fb5 @hakimio committed Apr 7, 2012
Showing with 29 additions and 0 deletions.
  1. +29 −0 Project/Assets/Scripts/Common/Helper.cs
@@ -110,6 +110,35 @@ public static class Helper
}
}
+ public static IEnumerator rotateLikeTarget(Transform target,
+ Transform transform, float rotationDuration)
+ {
+ float t = 0;
+ Quaternion rotation = transform.rotation;
+
+ while (t < 1)
+ {
+ t += Time.deltaTime * (Time.timeScale / rotationDuration);
+ transform.rotation = Quaternion.Slerp(rotation,
+ target.rotation, t);
+ yield return null;
+ }
+ }
+
+ public static IEnumerator rotate(Transform transform, Quaternion rotation,
+ float rotationDuration)
+ {
+ float t = 0;
+ Quaternion myRotation = transform.rotation;
+
+ while (t < 1)
+ {
+ t += Time.deltaTime * (Time.timeScale / rotationDuration);
+ transform.rotation = Quaternion.Slerp(myRotation, rotation, t);
+ yield return null;
+ }
+ }
+
public static Texture2D getImage(string name)
{
return (Texture2D)Resources.Load(name, typeof(Texture2D));

0 comments on commit 8f2e8ff

Please sign in to comment.