I am trying to make my own weather system of sorts and currently the way it works is if an object (sun for example) enters a trigger collider then a weather type of choice is enabled. Currently it works but very primitively as the weather is simply a GameObject which is being set to true or false via SetActive but because i have attached volumetric fog and clouds to it, the whole weather just pops in and out, but I want the clouds and fog to fade in at least visually over let’s say 10 seconds if the sun object enters the trigger collider. I have looked all over the internet but I have not found a way to control, let’s say Volumetric Cloud density or something like that through code and there isn’t much discussion about this.
(The SnowFall and Blizzard and their child objects in the image below are the ones getting enabled and disabled)
This is how my super primitive weather works in code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
public class EnableDisable : MonoBehaviour
{
public GameObject Affector;
public GameObject Affected;
void Start()
{
}
void Update()
{
}
private void OnTriggerEnter(Collider other)
{
if (Random.value > 0.5)
{
Affected.SetActive(true);
}
}
private void OnTriggerExit(Collider other)
{
Affected.SetActive(false);
}
}
Any input will be highly appreciated, thanks!
(Sorry if any of this seems obvious but my coding skills are extremely limited)