Dev Diary 009: Heavy Metal (with working example)

Matt Barton's picture

Well, I'm happy to say I'm back in the saddle again, excited about making some games with Unity. After watching the complete series on 3D Buzz about building a simple 2D game, I think I know enough to at least get started actually MAKING something again. I thought I'd start with something very simple: create a block that you can move around with the arrow keys, wrapping if you hit the borders, and for frills throw in a background and make the block rotate. I figured this was a complex enough project to take a noob like me the better part of a day, but--SHOCK--it only took a few minutes! Holy COW, those 3D Buzz videos made a difference.

I'm guessing my code (C#) would make a pro have a seizure, but it obviously works. The hardest part was making the point light follow the block around. That wasn't part of the original tutorials, but I had a thought--since the light is a game object with the same components as the rest (transform being the key here), could I make a script for it? Sure, enough, I was right. LOVE it when a plan comes together! The next problem was how to make it follow the cube...I decided to make a public variable-- a public GameObject variable to be precise and put it in my light script. Then I just drag'n dropped the cube onto the variable. WHOOP! It worked!

Okay, I realize I'm being ridiculous here, but man, it feels so good when something like that just works right out of the box. Once I had the script recognizing it, I was able just to tell the light to follow the cube's positioning (adjusting the z axis a bit so it was above it), and that was that. I'm still a little dizzy that it was that easy to do. I was expecting a nightmare!

Rotating the cube was a bit tricky. For some reason, the rotations was making the movement all wonky, so I had to figure out how to tell the movement script to act in world space rather than local space. I don't claim to know what this means, but my guess is that if you rotate something, say along the X axis, it affects what it means when you say to move in the X direction. Now that I'm thinking about it, it makes perfect sense. Duh. So by telling it to act in world space instead, it works just fine.

So, anyway, I realize this is probably a whole helluva lot more exciting for me than anyone else, but I'm starting to see a light at the end of the tunnel again. I'm pretty sure in a few weeks I'll have something decent to show. My first project will be a "baby project" called Heavy Metal Metal Blocks. The idea is to have the cubes coming down, and maybe you either have to dodge them or perhaps shoot them. I was kinda toying with the idea that shooting them would rotate them, and perhaps they'd have faces with different colors, so maybe you have to line up three of the same color to zap the line or some such. Think Space Invaders + Match 3. The main appeal for me will be the soundtrack, which I want to be a completely over-the-top Spinal Tap kind of thing.

See the web version of the project below.

Unity Web Player | WebPlayer

Comments

TripHamer
TripHamer's picture
Offline
Joined: 07/31/2010
Nice.

Looks like a good start!

I had to install the unity player.

I right clicked on the unity window and select "about unity player" and it took me to a download page, I downloaded, installed and refreshed the page....in firefox and the demo showed up.

n/a
clok1966
Offline
Joined: 01/21/2009
Alwasy good to see progress.

Alwasy good to see progress. keep taking small steps and you would be suprised how they all add up to something big.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.