Overview

Recently, I posted a video of a “Zone-Based” Weather System on Reddit and Twitter which gained  traction and interest. I decided to create this tutorial for anyone who may be interested in adding something similar to their own game. If you haven’t already, please consider joining some of the Holomento Communities if you are interested in the game; I am on Twitter, Reddit, Discord, and YouTube.

Before I dive into how this system works, I’d like to discuss what this system actually is. The system has 5 main parts:

    • Atmosphere Enum
      •  The Atmosphere Enum defines the different atmospheres the system will have. These could be weather or darkened lighting for indoor areas.
    • The Player
      • The Player is the actor that triggers overlaps in the zones. The Player also contains the particle system emitter that will be used for rain/snow/falling leaf particles.
    • The Zones
      • These are the overlap regions that will trigger atmosphere changes and particle effects when the player walks over them.
    • An Atmosphere Manager
      • This blueprint handles managing the atmosphere presets as the player interacts with zones. 
    • The Atmosphere Presets
      • These are your preset atmosphere actors (organized by weather). These can include Atmospheric Fog, Exponential Height Fog, Light Sources, The Sky Sphere and Sky Lights.

All of these parts work together to create a system that changes a template particle system on your player and changes your atmospheric settings using a pre-determined list of presets. This will allow you to set atmospheric settings for different regions and spawn particles for those regions.

Now that you know what the system is, I’ll explain how I did it!

Atmosphere Enum

First, we will need to create an “Atmosphere Enum”. This will define the different atmosphere and weather types we want to display. I suggest choosing short, single word display names for your enumerators. For example I have used “Default” for the sunny, clear sky atmosphere that is the fallback atmosphere in Holomento. I have also added the Overcast and HeavyFog enumerators for rain and snow respectively.

The NoChange enumerator is important as this will be used when we don’t want to change the current atmosphere settings.

Example Atmosphere Enum - The NoChange and Default Enumators are key here.

The Player

For the purposes of this tutorial, the player is a character blueprint with a particle system attached. This particle system’s template will be changed to add various weather effects. Beyond this, not much else is added to the player.

Particle System Component on Player

The Zones

Zones are simple blueprints with a single box collision component that is used for determining overlap with the player. Zone BP’s also only contain a single variable – a ZoneData struct. For the purposes of this tutorial, your zone struct will only need to contain the vars circled in red below.

The “ZoneParticleSystem” will change the player template particle system when we enter a zone. Leave the default value of this system as “None”. The “Atmosphere Setting” is a variable using our Atmosphere Enum. I suggest setting this to “NoChange” as the default value. Your Zone_BP should look something like the following:

We will come back to the Zone_BP to add overlap functionality after we setup our Atmosphere Manager and Atmosphere Presets.

Atmosphere Presets

Our atmosphere presets are simply the atmosphere actors in the scene organized by category. Below is an example:

Each of these will be added to an array for each corresponding Atmosphere category. These actors are where you will change how you want the atmosphere to look for each setting. For example, on the “HeavyFog” setting I increased the exponential height fog density and reduced the fog height falloff compared to the “Default” exponential height fog.

The Atmosphere Manager

The Atmosphere Manager is where all the magic happens. You will need to create an actor array for each of your atmosphere presets defined in your enum (these should also match the presets in your scene!) It is also important that all of these arrays are “Instance Editable” so that you can add your presets to them when you place the Atmosphere Manager in the scene. In addition you will need to create a player reference variable with the same type as your Player BP and 4 functions: SetAtmosphere, ActivateDeactivateActors, Enter Zone and Exit Zone.

In the ActivateDeactivateActors function, we will set the inputs to an actor array and a boolean named “Set Active?” This function will handle setting the visibility of all actors in the Atmosphere Preset arrays we defined earlier, as well as refreshing the Sky Sphere material should we need to do so. See below for details on how to setup the function.

Next up is the “Set Atmosphere” function. This function deactivates all atmosphere actors and then reactivates specific actors based on the selected Atmosphere Enum. See below for details:

Set Atmosphere Overview
Check for "NoChange"
Deactivate All Preset Actors
Activate Actors Based on Selected Preset

The Enter Zone and Exit Zone functions are where we set the particle template and set the atmosphere preset. Enter zone passes the Zone struct we defined earlier as an input. In the exit zone you can set the atmosphere to your default preset. I control this with a variable that changes on a run-by-run basis in Holomento. Details below:

Enter Zone Function
Exit Zone Function

Finally, during Event BeginPlay we will get the Player Reference and set the Atmosphere to the default setting. See Below:

Set Player Ref and Atmosphere on BeginPlay

Bringing It All Together

Finally, let’s return to the Zone_BP and setup overlapping functionality. Create a variable called AtmosphereManagerRef and set the reference in BeginPlay as below:

Zone_BP Event BeginPlay

Next, create an On Component Begin Overlap Event and On Component End Overlap Event for the Overlap Region component. Call the Enter Zone and Exit Zone functions from the Atmosphere Manager BP after casting to the Player BP as below:

Handle Overlap for Zone_BP

Finally, add a zone to the world and add a particle system and the desired atmosphere setting for this zone. I suggest that you use world-space particles for your rain/snow and other particle effects. This will give the illusion of the effect happening everywhere even though it is concentrated to only a small region around the player (this improves performance as well)! An example is circled in red.

Setting the Zone Particles and Atmosphere Settings

After that, add an Atmosphere Manager BP to the level and assign all of your presets to their respective actor arrays. See below:

Applying World Presets to Preset Arrays on the Atmosphere Manager

After this is done, test the level with your player and you should see that when you walk into the overlap region the atmosphere presets change and your particle system begins playing. When you exit the region the atmosphere presets should reset to your default settings and the particle system will stop playing.

Conclusion

I hope you found this tutorial helpful to get you started on creating your own Zone-Based Particle and Weather System in UE4! In the future, I will be adding more atmosphere variants and sounds to the system. I also will be figuring out the best method to gradually shift the weather effects rather than just having them pop-in instantly.

Thank you for reading and have a good day everyone!

– Sean