Adding fog zones
This commit is contained in:
@@ -2,8 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class Movement : MonoBehaviour {
|
public class Movement : MonoBehaviour {
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
|
|||||||
48
Assets/Scripts/TriggerEffects/FogZone.cs
Normal file
48
Assets/Scripts/TriggerEffects/FogZone.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class FogZone : MonoBehaviour {
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private Color fogColor = Color.white;
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("Default: 0.01")]
|
||||||
|
private float fogDensity = 0.01f;
|
||||||
|
[SerializeField]
|
||||||
|
private float fadeSpeed = 1;
|
||||||
|
private float t = 0;
|
||||||
|
private bool enabled = false;
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update () {
|
||||||
|
if (t < 1 && enabled)
|
||||||
|
{
|
||||||
|
RenderSettings.fogColor = Color.Lerp(RenderSettings.fogColor, fogColor, t);
|
||||||
|
RenderSettings.fogDensity = Mathf.Lerp(RenderSettings.fogDensity, fogDensity, t);
|
||||||
|
}
|
||||||
|
t += fadeSpeed * Time.deltaTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LerpFogSettings()
|
||||||
|
{
|
||||||
|
enabled = true;
|
||||||
|
t = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
Debug.Log("Changing fog");
|
||||||
|
LerpFogSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTriggerExit(Collider other)
|
||||||
|
{
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/TriggerEffects/FogZone.cs.meta
Normal file
11
Assets/Scripts/TriggerEffects/FogZone.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9a811801b5a922246ae15775e7f9c5be
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user