2012/07/29

grid movement and runtime snapping

Well, I just sent my second submission. There are three examples included, one showcasing grid-based movement, one showcasing how to place objects on a grid during gameplay and the lights-out game mentioned below. i also made tutorial videos for the first two, showcasing how you can accomplish these tasks in a simple manner on your own:


2012/07/27

a quick update

I have been contacted by an Asset Store admin, who recommends me to include a demo scene so users could see an end setup. I thought dragging a script onto an object is pretty straight-forward, but I agree, a demo scene would be a really good idea. The tricky party is coming up with good ideas; don't get me wrong, I have plenty of ideas for actual gameplay examples, but for a demo scene I need something more basic and at the same time more catchy. I already made a little sphere that randomly roams a grid face by face, stays within limits and immediately adapts to changes in the grid, all with just 32 lines of code total (not counting whitespaces and comments). I'll come up with two or three more nice demos, that should give a good impression of Grid Framework  in action.

2012/07/22

Almost there...

Well, it's alsmost done. Again. Turns out that making an asset is only half the job, you still need to hammer out any ugly dents, polish the thing and then change your job to become a graphic designer, a video commentator, a writer and a salesman! What good is the best asset if you present it in such a way that makes people not even want to take a look? I'm not claiming that I'm an expert in any of those fields, but I believe I did a pretty good job (well, maybe my voice work for the video could use some improvements). In a way I'm glad the old "images" I had prepared for the first version are now lost forever, that was something to turn people away forever. You cannot imagine how awful those looked.

Anyway, I finished the videos, I made the drawings for the asset store and I wrote the documentation. The only things left now are uploading the videos (which will take quite a while with my connection), writing a description text for the asset store (shouldn't be too much, so it won't take too long) and then sending the files over to Unity. In the meantime, please enjoy a small teaser:

Unfortunately clicking this won't do anything. Yet.

2012/05/29

Turn off the lights!

Here is a nice little puzzle game made using the grid framework. When you click a square that square and the four adjacent squares flip their color. Your task is to turn them all off.

The entire game uses only two scripts with a total of 70 lines of code. Sure, that may not seem like a small amount, but keep in mind that almost half of that is just whitespace and comments for better readability. The other half is mostly just to handle the user's input and only two lines are used for grid-based operations, i. e. finding out which tiles to flip. What's even better is that this works for any setup, you can even have holes and weird apendages like in the above picture. You could even move tiles during gameplay or generate the puzzle dynamically rather than by hand every time. Grid framework always finds the right tiles for you.

I will put up a video tutorial eventually once the package is released. I used delegates and events, so if you don't know what they are take a look at prime31studios' video tutorial:

2012/05/14

State of the Game

It has been over a month since I posted the introductory video and sent my application to Unity. I never received any confirmation, so I assume it got lost somewhere along the way...
Anyway, that doesn't mean I have been sitting here for over a month staring at the screen and refreshing my mail. I started working on this project because I needed a simple solution for one certain problem, that's how I started working and over time more and more ideas came to my mind. It was clear that I would need a complete rewrite sooner or later, so I decided to release a simple version first and then start the rewrite instead of throwing everything up to that point out the window.

When I sent my submission to Unity I was done with the old concept and started working on the new, more robust concept that would allow for far more features to be implemented cleanly. This meant switching to C# (since some things just aren't possible in UnityScript) and diving deeper into the documentation than ever before. I like the results. I set myself a few goals and so far I have achieved most of them. This includes:

  • grids as components instead of plain classes
  • fully support 3D grids and rotation
  • functions to find vertices, faces and boxes with just one line of code
  • a nice panel for aligning and scaling instead of that dirty workaround
  • switch between grid coordinates and world coordinates (and vice-versa) with just one line of code
  • every kind of grid (quare grid, hex grid, triangular grid) inherits from one common Grid class
Most work has been done under the hood to keep the code clean. It's easy to insert a new feature into clean code where I can leverage already existing methods instead of having to write the same thing several times (copy-pasting chunks of code is an awful idea!).
The one thing that still needs a good look are the methods related to the vertex matrix, it's one of those things that are easy to break if you aren't careful.

That said, once it's done the (hopefully now) first release would be ready to ship. I'd also have to rewrite the entire documentation and draw new logos for the Asset Store (in a way I'm glad my first submission got lost, those "drawings" were just aweful)
The fist release would only cover rectangular grids with hex grids added next, then finally triangular grids. I haven't started implementing them, but I have already done the math and I know how to do it, I just need to finish this first. The one last thing I can think of is grid pathfinding, but I won't even waste a thought on that until I get the other stuff done.

2012/04/11

Introduction video

As promised, here it is:
[video deleted]
A basic overview of what the first release has to offer. Stay tuned for future updates. The package is waiting for approval now.

2012/04/09

Introduction

Hello everyone :)

I have been working on making a 2D platformer in Unity in the spirit of the old 8 Bit and 16 Bit games such as Super Mario and Sonic. One thing I really admire about those games is their sense of clockwork-like precision, you never feel cheated by the controls, you always know which jumps you can make and which ones you can't.

Part of this precision comes from how these games can easily be broken up into blocks. For example Mario is either 1x1 blocks or 1x2 blocks large (actually it's slightly less, but let's not get lost in details here), he can jump a certain height and certain distance at a certain given speed and the level designers can easily calculate how many blocks they need to use to make the game just challenging enough to be fun but not unfair.

Consequently, I would have to do the same thing. I would need to come up with a certain block size (let's say 1x1 in Unity units) and adjust the scale and position of everything accordingly by hand. Not fun at all. Wouldn't it be awesome if Unity had some sort of grid framework, some way of specifying the grid's spacing and origin and just have the computer do the rest? Couldn't the computer scale and position my blocks inside the grid instead of me?

Well, if you need it, then make it, that's what I told myself. After coming up with an approach and a long-term plan of what to do I made the first step, a 2D grid class that can be used for scaling and alignment. The script will match you objects as closely to the grid as possible, so if your block is slightly larger it will shrink and if it's slightly smaller it will grow. With just a single key combo you can turn this messy Breakout field
into this clean arrangement

Actually, it took me longer to put those blocks into the scene than to align and scale them. As you can see some blocks didn't even have the right proportions.

Of course aligning and scaling is not all this is good for. As I mentioned before, the 2D grid is a class and as such can be used for scripting as well. The functions for scaling and aligning are built into the class so you can perform these actions during runtime. You could use the grid for path finding or anything you want. Every grid contains a matrix of its vertices, allowing you to instantly read any point within a specified range just by providing the coordinates, no math needed. Every grid is infinite in size since it's only defined by origin and spacing (the vertex matrix obviously isn't infinite) so there are no limitis to how far you can go with this grid.

I'm currently doing some polishing and fixing minor bugs. A promotional YouTube video will be coming soon, I finished writing the script, now I need to record it. Once I'm done the assets (including the documentation with scripting reference) will be avaible in the Unity Asset Store for an affordable price.
The future plans are to properly support 3D grids with rotation, make the interface more convenient, have mouse snapping in the editor, hex grids and whatever else I can come up with.