shawn's blog

……moar clouds (part one)…..

Posted in Other by Shawn on January 21, 2011

If you have been following anything that has been going on here, you would have already seen clouds. If you haven’t, you can browse through a few of the older post. All of the clouds being worked on were for OriGamInc’s Project S. I guess it’s almost common sense that this game will take place somewhere among the skies.

Creating clouds in XNA are a bit different that creating clouds in Unity (go figure!). While it is possible to create 3D clouds in both, it is probably much easier to create 2D in XNA, mostly with sprites. In Unity, being a much more refined ‘engine’ (engine being used loosely, as you may not necessarily apply the word to XNA), there are particle emmiters which make it quite simple to create clouds.

For Project S, I’ve decided to work on building the environment first. In terms of clouds, there were a few options. Non-moving clouds/moving player, non-moving player/moving clouds, both moving. This is ignoring how clouds would be created (either a sprite or a particle emitter, 2D or 3D). For now, I have decided to have both the clouds as well as the player move. This meant I would need to make clouds that would rise.

A blue backdrop

First, however, the clouds needed to be in the sky, which meant I needed a sky environment. Most skies nowadays pretend to be blue. In order to mimic this, the only thing I needed to do was to change the directional light object to blue. Easy, even for me.

Next, I needed to create clouds. The normal particle emmitter simply shoots out shiny particles. While they are pretty, I needed something different. If you create a texture of some kind, you can replace the original particles with your own, potentially creating funny effects or, in this case, clouds. This cloud was the same cloud that I spawned numerous times in the XNA version of clouds. Thanks to the particle emmitter, the clouds would be shot out from a single point in various directions in the x, y, and z axis. However, they were bound by an ellipsoid, helps them maintain their shape.

A happy cloud

Creating a cloud and having it move up wasn’t that bad. All I need to do was apply a translate code

transform.Translate(Vector3(0,cloudSpeed,0) * Time.deltaTime);

with cloudSpeed being the rate at which I wanted it to move. I left this as a variable to allow me to alter the speed in play mode. One problem that occurred quickly was that the clouds moved as a stream instead of as a bunch. This would happen if the clouds moved too fast, and the Ellipsoid containing them was not wide enough. Tweaking them has left me with a decent structure. The first part was done. I had a moving cloud.

That’s it for now. Next time, we’ll spawn clouds!

Tagged with: ,

Comments Off on ……moar clouds (part one)…..