Seven is the number.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB

  1. using System;
  2. using UnityEngine;
  3. using Random = UnityEngine.Random;
  4. namespace UnityStandardAssets.Effects
  5. {
  6. public class FireLight : MonoBehaviour
  7. {
  8. private float m_Rnd;
  9. private bool m_Burning = true;
  10. private Light m_Light;
  11. private void Start()
  12. {
  13. m_Rnd = Random.value*100;
  14. m_Light = GetComponent<Light>();
  15. }
  16. private void Update()
  17. {
  18. if (m_Burning)
  19. {
  20. m_Light.intensity = 2*Mathf.PerlinNoise(m_Rnd + Time.time, m_Rnd + 1 + Time.time*1);
  21. float x = Mathf.PerlinNoise(m_Rnd + 0 + Time.time*2, m_Rnd + 1 + Time.time*2) - 0.5f;
  22. float y = Mathf.PerlinNoise(m_Rnd + 2 + Time.time*2, m_Rnd + 3 + Time.time*2) - 0.5f;
  23. float z = Mathf.PerlinNoise(m_Rnd + 4 + Time.time*2, m_Rnd + 5 + Time.time*2) - 0.5f;
  24. transform.localPosition = Vector3.up + new Vector3(x, y, z)*1;
  25. }
  26. }
  27. public void Extinguish()
  28. {
  29. m_Burning = false;
  30. m_Light.enabled = false;
  31. }
  32. }
  33. }