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