TranslateCurve.cs 708 B

1234567891011121314151617181920212223242526
  1. /// ProFlares - v1.08 - Copyright 2014-2015 All rights reserved - ProFlares.com
  2. using UnityEngine;
  3. using System.Collections;
  4. namespace ProFlares {
  5. public class TranslateCurve : MonoBehaviour {
  6. Transform thisTransform;
  7. Vector3 pos;
  8. public float speed = 0.3f;
  9. public WrapMode wrapMode;
  10. public Vector3 axis = Vector3.one;
  11. public AnimationCurve Curve = new AnimationCurve(new Keyframe(0, 0.1f), new Keyframe(0.5f, 1.0f), new Keyframe(1.0f, 0.1f));
  12. void Start () {
  13. thisTransform = transform;
  14. pos = thisTransform.localPosition;
  15. Curve.postWrapMode = wrapMode;
  16. }
  17. void Update () {
  18. thisTransform.transform.localPosition = pos+(axis*Curve.Evaluate(Time.time*speed));
  19. }
  20. }
  21. }