Jump to content

Stopping Rain Inside Apartment


Colin MacLeod
Go to solution Solved by Bryan,

Recommended Posts

I saw some similar threads but couldn't find a solution for my case.

I have a roughly rectangular apartment and would like to show weather outdoors, through the window.

Added a "Gaia Interior Weather Volume" but it seems to still rain inside the  apartment. Here is a video of what I'm trying:

Unity: 2022.3.10f1

OS: macOS Sonoma 14.0 on Apple Silicon M2 Pro

Gaia: Gaia PRO 2023 4.0.4

Link to comment
Share on other sites

Hi @Colin MacLeod, we do not know yet why it happens, but it looks like Gaia does just not select your camera automatically in the Interior Weather Controller anymore. Can you please try to drag and drop your camera into the slot for "Player Transform" on the component?
This should make the component work as designed and switch off the rain inside the building.

 

Link to comment
Share on other sites

@Peter I did also notice I'd sized the volume via the Scale - I changed the scale to 1, 1, 1 and sized the Trigger Size. It seemed to make no difference.
Switching Controller Mode between Collision and Disable VFX doesn't seem to change anything either.

Link to comment
Share on other sites

  • Solution

So this isn't going to work for what you are trying to achieve. 
This is because this wasn't built for what you are trying to do. 
I recommend adding in some planes, removing the first material, and then adding the PWS_VFX_Rain. 
Then place these outside the window. 

The Interior Weather Controller is a triggered event. 
Then if it is triggered it would simply disable the weather effect. 

Then just add the audio when the plane is enabled. 
Either all the time or enabled on time. 
Still would need to create a script if you wanted to disable and enable it. 

You may want to turn up the Weather Intensity on the shader. 

image.png

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 4 months later...
On 10/11/2023 at 9:33 PM, Bryan said:

I found these posts highly helpful when I came back to removing rain from inside my buildings. I didn't want to use "InteriorWeatherController' because I already have boxes around my buildings to trigger asynchronous scenes for their interiors, and the IWC script didn't work very well. Anyways, I hashed out a custom version with the help of ChatGPT, and I'm leaving it here for other people who want to use your planes outside windows solution. This switches off the Gaia rain audio while inside so I've added an option for a muted audio track to play in the building. 

Hopefully this will speed up development for someone else.

using UnityEngine;
using Gaia;

public class CustomInteriorWeatherController : MonoBehaviour
{
    public AudioSource mutedRainAudioSource; // Reference to the muted raining audio source
    public GameObject[] outdoorRainPlanes; // Array of planes with rain effect outside windows
    private Collider buildingCollider; // Reference to the collider around the building
    private bool isIndoors = false; // Flag to track if the player is indoors
    private ProceduralWorldsGlobalWeather m_weatherSystem;
    private ParticleSystem m_rainParticleSystem;
    private MeshRenderer m_rainParticlesMeshRenderer;
    private GameObject m_particleSystemRainObject;

    private void Start()
    {
        buildingCollider = GetComponent<Collider>(); // Get the collider component on this GameObject
        buildingCollider.isTrigger = true; // Ensure the collider is set as a trigger
        m_weatherSystem = FindObjectOfType<ProceduralWorldsGlobalWeather>(); // Assuming there's only one instance
        m_rainParticleSystem = m_weatherSystem.m_rainVFX;
        m_rainParticlesMeshRenderer = m_weatherSystem.m_rainParticles;
        m_particleSystemRainObject = m_rainParticlesMeshRenderer.gameObject;
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player")) // Assuming the player has the "Player" tag
        {
            isIndoors = true; // Set indoors flag
            SetOutdoorRainPlanes(true); // Enable raining window planes
            DisableRainEffect(); // Disable rain effect inside the building
            DisableParticleSystemRain(); // Disable Particle System_Rain when indoors
            if (m_weatherSystem.IsRaining)
            {
                if (mutedRainAudioSource != null)
                {
                    mutedRainAudioSource.enabled = true;
                }
            }
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            isIndoors = false; // Set indoors flag
            SetOutdoorRainPlanes(false); // Disable raining window planes
            EnableRainEffect(); // Enable rain effect outside the building
            EnableParticleSystemRain(); // Enable Particle System_Rain when outdoors
            if (mutedRainAudioSource != null)
            {
                mutedRainAudioSource.enabled = false;
            }
        }
    }

    private void SetOutdoorRainPlanes(bool active)
    {
        if (m_weatherSystem != null)
        {
            if (m_weatherSystem.IsRaining)
            {
                foreach (GameObject plane in outdoorRainPlanes)
                {
                    plane.SetActive(active);
                }
            }
            else
            {
                // If it's not raining, deactivate the rain planes
                foreach (GameObject plane in outdoorRainPlanes)
                {
                    plane.SetActive(false);
                }
            }
        }
    }

    private void DisableRainEffect()
    {
        // Check if the weather system is available and it's raining
        if (m_weatherSystem != null && m_weatherSystem.IsRaining)
        {
            // Disable rain mesh renderer
            if (m_rainParticlesMeshRenderer != null)
            {
                m_rainParticlesMeshRenderer.enabled = false;
            }
        }
    }

    private void EnableRainEffect()
    {
        // Check if the weather system is available and it's raining
        if (m_weatherSystem != null && m_weatherSystem.IsRaining)
        {
            // Enable rain mesh renderer
            if (m_rainParticlesMeshRenderer != null)
            {
                m_rainParticlesMeshRenderer.enabled = true;
            }
        }
    }

    private void DisableParticleSystemRain()
    {
        // Disable Particle System_Rain object
        if (m_particleSystemRainObject != null)
        {
            m_particleSystemRainObject.SetActive(false);
        }
    }

    private void EnableParticleSystemRain()
    {
        // Enable Particle System_Rain object
        if (m_particleSystemRainObject != null)
        {
            m_particleSystemRainObject.SetActive(true);
        }
    }
}

  

 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...