CameraUtilities.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. using System.Collections;
  3. public class CameraUtilities
  4. {
  5. /// <summary>
  6. /// Smoothes a Vector3 that represents euler angles.
  7. /// </summary>
  8. /// <param name="current">The current Vector3 value.</param>
  9. /// <param name="target">The target Vector3 value.</param>
  10. /// <param name="velocity">A refernce Vector3 used internally.</param>
  11. /// <param name="smoothTime">The time to smooth, in seconds.</param>
  12. /// <returns>The smoothed Vector3 value.</returns>
  13. public static Vector3 SmoothDampEuler(Vector3 current, Vector3 target, ref Vector3 velocity, float smoothTime)
  14. {
  15. Vector3 v;
  16. v.x = Mathf.SmoothDampAngle(current.x, target.x, ref velocity.x, smoothTime);
  17. v.y = Mathf.SmoothDampAngle(current.y, target.y, ref velocity.y, smoothTime);
  18. v.z = Mathf.SmoothDampAngle(current.z, target.z, ref velocity.z, smoothTime);
  19. return v;
  20. }
  21. /// <summary>
  22. /// Multiplies each element in Vector3 v by the corresponding element of w.
  23. /// </summary>
  24. public static Vector3 MultiplyVectors(Vector3 v, Vector3 w)
  25. {
  26. v.x *= w.x;
  27. v.y *= w.y;
  28. v.z *= w.z;
  29. return v;
  30. }
  31. }