- Home /
2d Rain, moving with Camera
I'm building a rain effect for a 2d side-scroller. To cut down on the number of particles at any given time, I've done (what I think is) the sensical thing and attached the particle system to the camera, so that only the visible portion of the level has any rain on it. The problem I'm running into is that either:
(a) I simulate in world space, and when the player falls, or moves quickly, the rain gets "sloshed about" and needs a few seconds to catch up and look normal again or (b) I don't simulate in world space, and it's pretty apparent that all the rain is moving with the camera.
Any advice?
Answer by Meater6 · Jan 06, 2013 at 06:20 PM
Here are some of your options that I can think of:
Increase the area of the rain beyond the screen (about 2 screen sizes for good measure), and make the system world space. This has some bugs when moving really fast, so it's only a quick fix...
The best shuriken particle system way I can think of is to make "cells" (not using triggers, but like a programmed grid that identifies which cell should have rain in it, made from a single script on a single Game Object), and instantiate a shuriken emitter (must have prewarm on) in every cell that the camera is seeing or may see. Still can have minor glitches, but I can imagine less than number 1.
Procedural generation. Very useful stuff to know, but can be hard to use (especially in this case). There used to be a tutorial project on this subject, in the example projects section, but I can't seem to find it now... odd. This way you can make sure there are no hiccups in your rain, but it will be difficult to make. Personally, procedural generation is a little confusing for myself, but with practice, it will become invaluable.
I hope one of these solutions answers your question!
Your answer
![](https://koobas.hobune.stream/wayback/20220613090512im_/https://answers.unity.com/themes/thub/images/avi.jpg)