More work with Unity this morning on my 2D game. This isn’t progressing as well as I’d hoped, or at least I don’t think it is…am I expecting too much from myself? I don’t know.

Anyway we began the lesson this week with an introduction to IF Statements (or Conditionals). Conditional things can only happen under certain circumstances (so if you flip a coin its either going to be heads or tails that wins) whereas an IF Statement allows you to ask a question. So in the case of the coin toss, the code to allow that to happen would look a little like this;

void Start() {

//Store either 1 or 2

int number =Random.random(1:3)

* (1 for a number greater than 0 and 3 for a number than itself)

Then the actual results code would be;

if(number==1){                                          if(number==2){

Debug.Log(“Heads”)           or                Debug.Log(“Tails”)

}                                                                      }

*== asks if two things are equal.

At least I think that’s how it goes, I’m not sure but I have a feeling it’ll be wrong. Nevermind.

What I do know following what was on the board is that the code can be simplified;


Debog.Log (“Heads”);




Understand that? Good ‘cos I’m not sure. The more I look at it the more it looks like its making sense to me but I don’t know if that’s a false positive or not.

Anyway, after this we moved onto the lesson where we were asked to write a few lines of code for a 5 second timer. I don’t have any shots of what I wrote but I do know  got it wrong and I had a whole 10 minutes of time to do this.

The correct code and how it should have looked.


After that we moved onto our spaceship game. Now the issues I had last session were still there and I had to replace all the code I’d lost. I’d managed, with some help, to replace the missing code and actually fix some of the errors myself (!) but there were others that I simply couldn’t get.

I’d been having a little look at Unity the previous day (and I can now devote my focus to it now that the room project has been handed in) and I managed to make a few assets for the graphics. I’d took a starry background from Google (turns out it was a NASA image, thanks!) and make some rocky textures to make it look like a space cave asteroid of some sort. With Ant’s help again I’ve managed to get the moving asteroids to knock into each other which will create a danger to the ship since that’s now rigged to restart the game if it touches anything its not supposed to.

Other than that, that’s about it for my accomplishments for this lesson. Ant has said he’s put up video recaps of what we’ve done so far which I’m going to watch (probably a few times) to see if I can get something to stick. I’m intending to see if I can create another level or to for game progression and if I’m extremely lucky I might be able to fluke my way through the coding to make that happen. But for now I’ve got to continue working on the walking simulator and get that ready for the presentation I’m supposed to give in a fortnight.

Unity for two weeks straight. Urk. I’ve started telling myself Shigeru Miyamoto isn’t a code and look what he can do….


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s