DemoPointLight.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace VolumetricFogAndMist {
  4. public class DemoPointLight : MonoBehaviour {
  5. public Vector3 attractionPos = new Vector3(-58, 3f, -19f);
  6. Vector3[] fairyDirections = new Vector3[VolumetricFog.MAX_POINT_LIGHTS];
  7. void Update () {
  8. const float accel = 0.01f;
  9. for (int k = 0; k < VolumetricFog.MAX_POINT_LIGHTS; k++) {
  10. GameObject fairy = VolumetricFog.instance.GetPointLight (k);
  11. if (fairy != null) {
  12. fairy.transform.position += fairyDirections [k];
  13. Vector3 fairyPos = fairy.transform.position;
  14. if (fairyPos.x > attractionPos.x)
  15. fairyDirections [k].x -= accel;
  16. else
  17. fairyDirections [k].x += accel;
  18. if (fairyPos.y > attractionPos.y + 1.0f)
  19. fairyDirections [k].y -= accel * 0.1f;
  20. else
  21. fairyDirections [k].y += accel * 0.1f;
  22. if (fairyPos.z > attractionPos.z)
  23. fairyDirections [k].z -= accel;
  24. else
  25. fairyDirections [k].z += accel;
  26. }
  27. }
  28. }
  29. }
  30. }