public static AnimationController AnimateRigidbody(Rigidbody animatedRigidbody, Vector3 newPosition, Vector3 newAngle, float duration, EaseInOutType type, AnimateObjectCompleted animationDelegate, object delegateParameter) { AnimationController newAnimation = null; if (animatedRigidbody != null) { newAnimation = AnimateObject(animatedRigidbody.gameObject, newPosition, newAngle, duration, type, animationDelegate, delegateParameter); newAnimation.m_AnimatedRigidbody = animatedRigidbody; } return newAnimation; }
public static AnimationController AnimateCamera(Camera animatedCamera, Vector3 newPosition, Vector3 newAngle, float newOrthographicSize, float duration, EaseInOutType type, AnimateObjectCompleted animationDelegate, object delegateParameter) { AnimationController newAnimation = null; if (animatedCamera != null) { newAnimation = AnimateObject(animatedCamera.gameObject, newPosition, newAngle, duration, type, animationDelegate, delegateParameter); newAnimation.m_AnimatedCamera = animatedCamera; newAnimation.m_NewOrthographicSize = Mathf.Clamp(newOrthographicSize, 1, newOrthographicSize); } return newAnimation; }
public static AnimationController AnimateObject(GameObject animatedObject, Vector3 newPosition, Vector3 newAngle, float duration, EaseInOutType type, AnimateObjectCompleted animationDelegate, object delegateParameter) { GameObject newAnimationObj = new GameObject(animatedObject + "_animation"); //newAnimationObj.transform.parent = animatedObject.transform; AnimationController newAnimation = newAnimationObj.AddComponent<AnimationController>(); newAngle = MathfPlus.GetClosestAngle(animatedObject.transform.eulerAngles, newAngle); newAnimation.m_AnimationDelegate = animationDelegate; newAnimation.m_DelegateParameter = delegateParameter; newAnimation.m_AnimatedObject = animatedObject; newAnimation.m_NewPosition = newPosition; newAnimation.m_NewAngle = newAngle; newAnimation.m_Duration = duration; newAnimation.m_Type = type; return newAnimation; }
public static AnimationController AnimateRigidbody(Rigidbody animatedRigidbody, Vector3 newPosition, Vector3 newAngle, float duration, EaseInOutType type, AnimateObjectCompleted animationDelegate, object delegateParameter) { AnimationController newAnimation = null; if (animatedRigidbody != null) { newAnimation = AnimateObject(animatedRigidbody.gameObject, newPosition, newAngle, duration, type, animationDelegate, delegateParameter); newAnimation.m_AnimatedRigidbody = animatedRigidbody; } return(newAnimation); }
public static AnimationController AnimateCamera(Camera animatedCamera, Vector3 newPosition, Vector3 newAngle, float newOrthographicSize, float duration, EaseInOutType type, AnimateObjectCompleted animationDelegate, object delegateParameter) { AnimationController newAnimation = null; if (animatedCamera != null) { newAnimation = AnimateObject(animatedCamera.gameObject, newPosition, newAngle, duration, type, animationDelegate, delegateParameter); newAnimation.m_AnimatedCamera = animatedCamera; newAnimation.m_NewOrthographicSize = Mathf.Clamp(newOrthographicSize, 1, newOrthographicSize); } return(newAnimation); }
public static AnimationController AnimateObject(GameObject animatedObject, Vector3 newPosition, Vector3 newAngle, float duration, EaseInOutType type, AnimateObjectCompleted animationDelegate, object delegateParameter) { GameObject newAnimationObj = new GameObject(animatedObject + "_animation"); //newAnimationObj.transform.parent = animatedObject.transform; AnimationController newAnimation = newAnimationObj.AddComponent <AnimationController>(); newAngle = MathfPlus.GetClosestAngle(animatedObject.transform.eulerAngles, newAngle); newAnimation.m_AnimationDelegate = animationDelegate; newAnimation.m_DelegateParameter = delegateParameter; newAnimation.m_AnimatedObject = animatedObject; newAnimation.m_NewPosition = newPosition; newAnimation.m_NewAngle = newAngle; newAnimation.m_Duration = duration; newAnimation.m_Type = type; return(newAnimation); }
public static float GetInterpolationRatio(float startValue, float endValue, float currentValue, EaseInOutType type) { if (endValue < startValue) { endValue = startValue; } if (currentValue < startValue) { currentValue = startValue; } float ratio = (currentValue - startValue) / (endValue - startValue); switch (type) { case EaseInOutType.Quad: return(Mathf.Clamp01(-(Mathf.Cos(Mathf.PI * Mathf.Clamp01(ratio)) / 2.0f) + 0.5f)); case EaseInOutType.Expo: return(Mathf.Clamp01(Mathf.Pow(Mathf.Clamp01(ratio), 2))); case EaseInOutType.ExpoInverse: return(-Mathf.Clamp01(Mathf.Pow(Mathf.Clamp01(ratio) - 1.0f, 2)) + 1.0f); case EaseInOutType.Cubique: return(Mathf.Clamp01(Mathf.Pow(Mathf.Clamp01(ratio), 3))); } return(ratio); // Linear }
public static float GetInterpolationRatio(float startValue, float endValue, float currentValue, EaseInOutType type) { if (endValue < startValue) endValue = startValue; if (currentValue < startValue) currentValue = startValue; float ratio = (currentValue - startValue) / (endValue - startValue); switch (type) { case EaseInOutType.Quad: return Mathf.Clamp01(-(Mathf.Cos(Mathf.PI * Mathf.Clamp01(ratio)) / 2.0f) + 0.5f); case EaseInOutType.Expo: return Mathf.Clamp01(Mathf.Pow(Mathf.Clamp01(ratio), 2)); case EaseInOutType.ExpoInverse: return -Mathf.Clamp01(Mathf.Pow(Mathf.Clamp01(ratio) - 1.0f, 2)) + 1.0f; case EaseInOutType.Cubique: return Mathf.Clamp01(Mathf.Pow(Mathf.Clamp01(ratio), 3)); } return ratio; // Linear }