liquid star
This commit is contained in:
1 parent
ba45c55d48
commit
b261f4d3d0
20 files changed
+1049
-18
No files matched your search
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class FlickerLight : MonoBehaviour {
|
||||
[SerializeField] float baseIntensity = 8f;
|
||||
[SerializeField] float flickerAmount = 2f;
|
||||
[SerializeField] float speed = 1.5f;
|
||||
|
||||
Light _light;
|
||||
float _offset;
|
||||
|
||||
void Start() {
|
||||
_light = GetComponent<Light>();
|
||||
if (_light) baseIntensity = _light.intensity;
|
||||
_offset = Random.value * 100f;
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (!_light) return;
|
||||
|
||||
float t = Time.time * speed + _offset;
|
||||
float noise = Mathf.PerlinNoise(t, _offset) * 2f - 1f;
|
||||
noise += (Mathf.PerlinNoise(t * 2.7f, _offset + 50f) * 2f - 1f) * 0.4f;
|
||||
|
||||
_light.intensity = baseIntensity + noise * flickerAmount;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user