Welcome to another short tutorial. This time we will make a quick mist effect.
In some languages (including my very own, Spanish), things like mist and fog can be confused because we use the same word for different things, so maybe I will make a clarification of terms. In this context, if I mention "fog" I will refer to the cloudy-yet-mostly uniform body that gradually increases its thickness in the distance, but that is not moving. I will call mist to the cloudy-mass that is moving from one direction to another due to the wind (similar to smoke running in one direction, but white instead of gray-black). I decided to make this effect to increase the quality of atmosphere in one of the projects being developed in my tiny game development studio.
To make the mist, I decided the best option was to use particles, so I could sell the effect of mist actually moving. Create a particle emitter and you will obviously get something like this:
The first thing you should do is set it so that the mist particles move in one direction (after all, wind will mostly move in one direction in your specific level, albeit with some turbulence here and there). Another thing you can do is change the emission shape to something that fits your needs. In my case, I use a box, because it will allow me cover a big horizontal area, while also keeping control on the vertical area of emission. Using a circle or a cone will end up in a lot of particles being generated in places you won’t see. Another useful thing is to change the rotation of the emitting shape, so your mist moves horizontally.
To render the particles, I created a simple particles material with a simple texture. You can create a texture yourself, or you can look for one on the internet, it’s up to you (personally I used a texture included in the game’s project). Also, if you want to be fancy, you can use a texture that includes a lot of tiles, although that is something I will not cover here. Another thing I need to mention is that my texture is pretty much gray-scale, so I can control the color of the mist with the material itself (I gave it a slight light-blue color so it would fit the color palette of the game).
The next step would be to tweak different aspects of the particle effect. Right now, the particles have different issues, including size and speed. For the mist to feel thick, we would need to use bigger particles, and also more particles. Also, it needs to move slower. Keep in mind these are just the values I used, but you may need to tweak them depending on the size of your scene, the scale (meaning how big your characters and objects are), and how much mist you need.
I wanted to simulate the mist coming down slightly, so I activated the "Force over Lifetime" section, and added -0.1 in a world-space to make the mist come down. It’s better for you to tweak it in a way that will fit your needs, because that amount may be either too little or too much for the effect you want. Another thing I did, to make it look more dynamic, is to activate the "Rotation over Lifetime" so the mist would get a more dynamic look.
Lastly, depending on your setup, you may need the mist to stop when it collides with the ground, unless you’ve set it in a way that it will never touch the ground. In my case, I did want the mist to collide with the ground, so I setup collisions with the floor as seen below.
Pay extra attention to the "Bounce" and "Radius Scale" values. Bounce will cause the particles to, as you guess, bounce off the collider. In some cases, you may want that, but it’s definitely something you don’t want in your mist, so I used a very low value just to avoid it being completely stuck to the ground after collision. The wrong Radius Scale may cause your particles appear like they "float" above the ground (see image below), and that’s why I decreased that value.
Keep in mind that, while this value respects the particle size, it may end up giving you a bad result visually, based on your particle size and also texture being used.
Lastly, to finish selling the effect, I created a fog effect in the Unity scene. For this particular effect I used an asset I got from the Asset Store (unfortunately the asset was retired), but you can create a similar effect using the Unity Fog.