private void CalculateDestination() { if (useLocalPosition) { float y = randomYRange.Random(); animationCurve.EditKeyframeValue(0, new Vector3(Camera.main.transform.position.x + 10, y, 0)); animationCurve.EditKeyframeValue(1, new Vector3(Camera.main.transform.position.x - 10, y, 0)); } else { animationCurve.EditKeyframeValue(0, new Vector3(gameObjectToManipulate.transform.position.x, gameObjectToManipulate.transform.position.y, 0)); } destination = animationCurve.Evaluate(animationCurve.MaxTime()); }
/// <summary> /// Animates the scale of a GameObject, relative to it's original scale, with a Vector3AnimationCurve. /// </summary> /// <param name="gameObject">GameObject to scale.</param> /// <param name="animationCurve">Vector3AnimationCurve to evaluate.</param> /// <returns>Coroutine</returns> public static Coroutine ScaleRelative(GameObject gameObject, Vector3AnimationCurve animationCurve) { var animationData = gameObject.AddOrGetComponent <AnimationData>(); return(StartCoroutine(gameObject, "ScaleRelative", Loop(gameObject, "ScaleRelative", animationCurve.IsLooping(), animationCurve.MaxTime(), elapsedTime => ScaleRelative(gameObject, animationCurve, elapsedTime, animationData)))); }
/// <summary> /// Animates the scale of a GameObject with a Vector3AnimationCurve. /// </summary> /// <param name="gameObject">GameObject to scale.</param> /// <param name="animationCurve">Vector3AnimationCurve to evaluate.</param> /// <returns>Coroutine</returns> public static Coroutine Scale(GameObject gameObject, Vector3AnimationCurve animationCurve) { return(StartCoroutine(gameObject, "Scale", Loop(gameObject, "Scale", animationCurve.IsLooping(), animationCurve.MaxTime(), elapsedTime => Scale(gameObject, animationCurve, elapsedTime)))); }
/// <summary> /// Animates the position of a GameObject with a Vector3AnimationCurve. /// </summary> /// <param name="gameObject">GameObject to move.</param> /// <param name="animationCurve">Vector3AnimationCurve to evaluate.</param> /// <returns>Coroutine</returns> public static Coroutine Position(GameObject gameObject, Vector3AnimationCurve animationCurve) { return(StartCoroutine(gameObject, "Position", Loop(gameObject, "Position", animationCurve.IsLooping(), animationCurve.MaxTime(), (elapsedTime) => Position(gameObject, animationCurve, elapsedTime)))); }