……moar clouds (finale)…..
If you noticed the interval between the clouds being generated, you would notice that they are the same. This meant if I created a level full of mostly fast clouds, even if they were at different heights, the intervals would remain the same. To add some more variety, all that was necessary was telling our clouds to spawn at random times. This meant changing the yield WaitForSeconds(int) to something that looks like:
yield WaitForSeconds(Random.Range(10, 15));
Hey! Now we’ll have clouds spawning anywhere from 10-15 seconds after the latest cloud. This actually turned out to be much easier than anticipated.
Now that we have clouds spawning at random intervals, we can work on adding a bit more variety in the cloud spawning. This can be done two ways. The first way would be to alternate the types of clouds being spawned. What needed to be checked was “What type of cloud did we just spawn?”. This could be done by creating a new boolean, which I called spawnAngryCloud().
if(spawnAngryCloud){spawnAngryCloud = false;var instanceAngry : GameObject = Instantiate(angryClouds, transform.position, transform.rotation);yield WaitForSeconds(Random.Range(26, 30));}else if(!spawnAngryCloud){spawnAngryCloud = true;var instance : GameObject = Instantiate(clouds, transform.position, transform.rotation);yield WaitForSeconds(Random.Range(26, 30));}
Again, doing this would cause consistency of some kind, something not too common within the cloud world (at least, that’s what I learn in my philosophy of clouds class). What I decided to do was reuse the Random.Range tool:
var whatCloud : int = Random.Range(2,11);
if(whatCloud % 2 == 0)
{
spawnAngryCloud = false;}else if(whatCloud % 2 == 1){
spawnAngryCloud = true;
}
I checked the remainder of a random integer from 2 – 11, which will either return 0 or 1. If it’s 0, we’ll get an angry cloud; 1 will spawn a normal cloud. Combined with the various interval script, and we have:
Lovely! Now, we can create fast, slow, and normal speed generators for each of our different types of spawning clouds, which should give us much more variety than initially.
Looks like we’re done with clouds for now. Later on, I plan to include an ‘evil’ cloud that….well, is evil and potentially hazardous to objects on the screen. I wonder how that cloud will look…..
……moar clouds (part tres)…..
pretend there’s an accent on the ‘e’
Part two had us finally creating clouds that would spawn. But left alone and these clouds would form a consistent stream of clouds. We can change this by altering the spawn rate for these clouds. Right now, the Instantiate code for clouds is in a separate function, with that function being called in Update.
function Update () {spawnCloud();}
function spawnCloud(){if(!didCloudSpawn){didCloudSpawn = true;var instance : GameObject = Instantiate(clouds, transform.position, transform.rotation);yield WaitForSeconds(27);didCloudSpawn = false;}
This isn’t all the variety we could put in. While this isn’t fully implemented, what we can do is give the cloud generator a random interval to pump out clouds. For example, we can say to the slow cloud generator “Generate a cloud anywhere from 30-35 seconds after you generated your most recent cloud” while telling the fast generator to say “Generate a cloud anywhere from 10-15 seconds after your most recent cloud”. This would cause even more organized instability within our skies.
Next time, I may try to put this feature into play, in addition to adding more code to release different types of clouds.
Comments Off on ……moar clouds (part tres)…..
……moar clouds (part duex)…..
At the end of part one, we finished the easier task of making the background for our clouds and picking the object that our particle emmiter will pump out consistently. Now we’re going to have to generate clouds. This can be done by using Instantiate, which is basically create.
var instance : GameObject = Instantiate( clouds, transform.position, transform.rotation);
Comments Off on ……moar clouds (part duex)…..
……moar clouds (part one)…..
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.
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.
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!
Comments Off on ……moar clouds (part one)…..
Work With Unity
This weekend has me spending a lot of time with Unity, and working through basic tutorials to get a feel for what I can/cannot do, and what happens when I hit every button at once (mostly nothing).
I have not created any scripts for controlling in game objects yet, which can also be implemented using methods I haven’t focused on as of now. This is my first real time experimenting with an engine of this kind. While this is a 3D engine, it is possible to develop 2D games through multiple methods. One could be creating 3D objects, but leaving the world in 2D, similar to games such as Super Smash Brothers. This seems more difficult, as you may need to work on fully creating 3D objects, as certain objects may show all their sides, as opposed to 2D objects, who are quite lazy.
Another option that I can pursue, as I saw from GameDevNewbie’s website is to have a depth of 1 (in one axis) for all of my objects. This would leave me less obligated to work on making full 3D objects.
This reason why I bring this up, is because currently, I am working with Microsoft’s XNA framework to develop for OriGamInc’s Project S. Once I started playing with Unity, I quickly thought of the possibilities of using it to work on the Project. However, if I abandon using XNA, I will lose a lot of time put into this. While I am currently learning more about XNA, I am also getting a better understanding of syntax for C#.
I will continue to use both tools for furthering my development skills, but eventually, I may find that I need to make a decision.
That’s it for now.
Comments Off on Work With Unity
Comments Off on ……moar clouds (finale)…..