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());
    }
Example #2
0
        /// <summary>
        ///     Changes the position of a GameObject, relative to it's original position, to the evaluated Vector3 calculated from
        ///     a Vector3AnimationCurve object.
        /// </summary>
        /// <param name="gameObject">GameObject to move.</param>
        /// <param name="animationCurve">Vector3AnimationCurve to evaluate.</param>
        /// <param name="elapsedTime">The time elapsed since the animation started.</param>
        /// <returns>void</returns>
        public static void PositionRelative(GameObject gameObject, Vector3AnimationCurve animationCurve,
                                            float elapsedTime)
        {
            var animationData = gameObject.AddOrGetComponent <AnimationData>();

            gameObject.transform.localPosition =
                animationData.TransformData.Position + animationCurve.Evaluate(elapsedTime);
        }
    public IEnumerator AnimateRotationCurve()
    {
        Vector3 rotation = rotationCurve.Evaluate(Time.timeSinceLevelLoad - _initializationTime);

        gameObjectToManipulate.transform.rotation = Quaternion.Euler(rotation.x, rotation.y, rotation.z);

        yield return(null);

        StartCoroutine(AnimateRotationCurve());
    }
Example #4
0
 /// <summary>
 ///     Changes the scale of a GameObject, relative to it's original scale, to the evaluated Vector3 calculated from a
 ///     Vector3AnimationCurve object.
 /// </summary>
 /// <param name="gameObject">GameObject to scale.</param>
 /// <param name="animationCurve">Vector3AnimationCurve to evaluate.</param>
 /// <param name="elapsedTime">The time elapsed since the animation started.</param>
 /// <param name="animationData">AnimationData object containing cached transform data.</param>
 /// <returns>void</returns>
 public static void ScaleRelative(GameObject gameObject, Vector3AnimationCurve animationCurve, float elapsedTime,
                                  AnimationData animationData)
 {
     gameObject.transform.localScale = animationData.TransformData.Scale + animationCurve.Evaluate(elapsedTime);
 }
Example #5
0
 /// <summary>
 ///     Changes the scale of a GameObject to the evaluated Vector3 calculated from a Vector3AnimationCurve object.
 /// </summary>
 /// <param name="gameObject">GameObject to scale.</param>
 /// <param name="animationCurve">Vector3AnimationCurve to evaluate.</param>
 /// <param name="elapsedTime">The time elapsed since the animation started.</param>
 /// <returns>void</returns>
 public static void Scale(GameObject gameObject, Vector3AnimationCurve animationCurve, float elapsedTime)
 {
     gameObject.transform.localScale = animationCurve.Evaluate(elapsedTime);
 }