shawn's blog

……moar clouds (finale)…..

Posted in Unity by Shawn on January 28, 2011

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.

Clouds Spawning at different intervals.

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));
}
Now, we check to see which cloud we’re spawning. Initially, spawnAngryCloud is set to false, which spawns a normal cloud. Right away, we set spawnAngryCloud = true to make sure that the next time we spawn a cloud, it will be angry. I placed this script on to a fast, normal, and slow generator, which gave me:
Alternating Clouds

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:

Different Clouds, Different Intervals

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…..

Tagged with:

Comments Off on ……moar clouds (finale)…..

……moar clouds (part tres)…..

Posted in Unity by Shawn on January 27, 2011

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();
}
spawnCloud()  is being called every time we update. However, if we left it alone, with just instantiate, we would many many (many) clouds, something we do not what, even if we wanted a foggy atmosphere. We will need to check if a cloud has spawned and wait. After we wait a certain amount of time, then we could check to see if we wanted another cloud to spawn.
function spawnCloud(){
if(!didCloudSpawn){
didCloudSpawn = true;
var instance : GameObject = Instantiate(clouds, transform.position, transform.rotation);
yield WaitForSeconds(27);
didCloudSpawn = false;
}
Initially, we set didCloudSpawn = false. Then when spawnCloud() is called in Update(), we will check to see if we should spawn a cloud. Since didCloudSpawn = false, we will set it to true and spawn a cloud right away. Now, when Update is called again (it’s called 60 times in one second I think), clouds will not spawn, because didCloudSpawn is set to true. So we must wait 27* seconds. After we wait the alloted time, we will set didCloudSpawn  = false again, allowing for an additional cloud to be spawned.
Last time, I did say we were going add a bit more variety. Well, for now, what we can do is create multiple cloud generator scripts and play with the yield WaitForSeconds line. What I did, was create three different scripts, a slow cloud generator, a normal one and a fast one. They each had different amounts in the WaitForSeconds line, which meant that different generators would spawn clouds at different rates. Which meant, after creating a few fast, normal, and slow generators, we could wind up with….

Moar Clouds!

It would be best to not place two fast cloud generators right next to each other, as this would create a bit too much consistency. So, instead, I was sure to place a slow generator next to a fast or normal one. In addition to this, not all the clouds needed to be on the same plane. They could vary in position on each axis (x, y, and z). This would mean that some clouds would appear to be bigger, when in reality, they’re just closer.

They're actually in 3D space

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.

Tagged with: ,

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

Writing for projects

Posted in Writings by Shawn on January 26, 2011

As I said at the end of Writing for….., I needed to work on a timeline for my story. This is a very simple take on what I wanted to fully do.

As more and more stories are developed within the world, more and more people are yelling “x is just a rip-off of y” or “y is just like z, without the explosions and guns!”. So the problem that I’m initially striving for is originality. Unfortunately, you’re going to run into that person who likes to reduce everything (ugh) to the point where your great idea is nothing more than the combination of Zelda and Mortal Kombat. So how do you write an original story for a video game?

One may argue that you cannot do such a thing, rather, what’s best to do is to find an existing product, tweak it, and make it better. Did this mean that I would need to find an existing story to model mine off of? Good Earthlings vs evil space mutants? Good Earthlings vs evil space mutants who aren’t really evil, but being controlled? Should a nobody save a princess and the world? The plus with this is that it’s easily identifiable, and I don’t really have to work too hard to think of new ideas. When I’m done looking at one reference, I can jump to another one that does something a bit differently. I then to something a bit differently than that one and ‘Wow, what an original* idea!’.

Bleh.

So, instead, I decided to go my own route, which I personally think is the much better route for me and this story and try to develop something completely original.

But, let’s make an argument first.

Unless I’ve never paid any attention to stories anywhere ever, my mind will be influenced by stories that I’ve heard of, seen, read etc. Does this mean that no matter what, no ideas of mine will be original? Everything that I may potentially work on will be based off something else. To an extent, I will acknowledge that my ideas often come from reading other stories, and becoming invested in the storylines of other games. However, this does not equal plagiarism, at least in my humble opinion. While Metal Gear Solid’s storyline is based off other spy themed stories, it does not really seem like that story. There are numerous references and illusions to James Bond, I like to think of the story as James Bond gone horribly wrong.

The best way that can find to develop something original is to use what I’ve seen and learned from other stories. But rather than find everything I liked about story X, find everything I did not like about the story. What do I think was bad? What seemed off, dumb, lame, cheesy, trite, boring, too complex for anyone to even understand, too dramatic, lazy, pointless, over thought, etc etc. Now, I can do two things with all the pieces that I did not like/fully agree with. One could be to ignore everything that I didn’t like, or I can aim to improve all of these areas and make them work within my own idea. Find the areas where I thought “It would have been much cooler if they did ‘x’ instead of ‘y’ “. So I tried that.

It worked to an extent…..which was nice. While it didn’t give me an instant masterpiece (I wasn’t really expecting that anway), it gave me something to start with. Something to put in the timeline.

The timeline then had moments that I wanted. Bigger moments or more important plot moments. Now everything had to connect, something much more difficult than I initially thought it would be….

……moar clouds (part duex)…..

Posted in Unity by Shawn on January 25, 2011

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);
This will create the initial cloud object. In Unity, it’s actually quite easy to apply a piece of code to an object; it’s simply a matter of drag and drop. And unlike those cloud makers that you see on the side of the road sometimes, these cloud makers needed to be invisible. To achieve this, you can create an empty game object. You can probably achieve the same result by creating a block, then turn off the rendering, but I haven’t tested yet, and this method seems a bit more practical, with less potential errors.

I know it's the same image, but it's filled with many empty game objects.

Before adding the Instantiate function onto the game objects, I had to remember to add the cloud movement command onto the clouds, to enable movement. I could then confidently (somehow) apply the instantiate script to the game objects to spawn lovely clouds.

Spawning clouds

Now we have clouds. But they’re not very exciting, albeit, clouds may not be the most exciting thing. However, if we just had clouds spawning consistently from these locations, we would wind up with a line of clouds, which end up providing a very monotonous background of clouds.
That’s it for now. We’ll look at spawning more clouds at different rates next.
Tagged with: ,

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

Writing for…..

Posted in Writings by Shawn on January 24, 2011

One thing that I still plan to do is to write. I took a few philosophy classes in college, and enjoyed them immensely. So much that I ensured that I would continue to do philosophy after I graduated. It was easy to apply philosophy to ‘more serious’ things such as politics and ‘adult’ things (the adult dinner table things, not the adult NSFW things…….), but I wanted to combine everything that I think I know about together. During one class, which focused primarily on the philosophy of time, every other class that I took seemed to apply to that class. My world became much more interconnected than it originally was, something exciting and frightening at the same time. This pushed me into pursuing philosophy but with everything that I do. Pragmatism did the same; everything I knew was affecting everything else I knew and was eventually about to encounter.

Basically….I wanted to pursue philosophy in video games, something that I am trying to do here as well. Unfortunately, time is usually not on my side. And I never have taken a time management class (do those even exist?), so I’m pretty bad at scheduling. Currently, I have a book of topics that I wish to develop into more than just scribbles and doodles.

The writing I plan to pursue applies to video games in a different light as well, as I am currently developing the story for a future (potentially massive) project.  The story that I’m writing aims to be complex and….well, interesting. Of course, many times, some people create stories that they believe are extremely interesting, and turn out to be mundane to the world. I do want to write something enjoyable to not only myself, but the people interacting with the story. This means that while I may include some plot twist and crazy events, I do not think that I’ll write a story that gets a bit out of hand from time to time. But maybe things start simple, and eventually explode in to a chaotic series of events that need a team of writers. If this project ever develops into something much bigger than a few journals, then I do plan to ask for help from others who enjoy writing as well. The more the merrier?

The project that I’m actually writing a story for is OriGamInc’s Project K.A. I haven’t had much time recently to work on that story, but hopefully things will change. My writing process for this story has me working on multiple revisions that grow and grow. What I have come to know from my past writings is that I just work on the complete story then go back and tinker with tidbits here and there. With Project K.A.’s story, my technique has changed considerably. Basically, I know all the big moments and how I want them to develop. This mean writing a….bleh….timeline.

Now, don’t get me wrong, I don’t hate timelines. They just feel too structured for my free-spirited mind(<— joke). Timelines remind me of outlines which remind me of papers that I did not enjoy writing throughout life. But, it’ had to be done to get this story started…..

……moar clouds (part one)…..

Posted in Unity 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)…..

Boxes and Stars

Posted in Unity by Shawn on January 20, 2011

I’ve been looking at a lot of Unity3D tutorials/books/documentation, and I put something together last night, which actually was quite easier than I was expecting.

It’s nothing spectacular. Floating boxes that are basically targets. Upon getting hit by a ball, they fall!

The stars are...not pretty.

Really bad textures are courtesy of me not really putting more than 3 mins into Paint.net. I would spend more time with this, but I do have bigger project I would like to work on, and not as much time as I would like.

Comments Off on Boxes and Stars