Grid Framework [scripting and editor plugins]

Hello everybody,

I’m announcing the first release of the Grid Framework for Unity3D, your simple solution for grid-based actions.

So, what does it do? You just drag the new grid component on an object in your scene, set the values to your liking and there you go. Now all you need is to make that game of yours without worrying about any equations and calculations. All grids are infinite in size, three-dimensional and can be freely moved and rotated using the object they are attached to. Find points in the grid and convert from grid space to world space and vice versa on the fly with just one line of code. Use grids for gameplay, in level design or for level design during gameplay. Snap objects to the grid or align them, both during runtime and in the editor with the included editor panel. Or maybe you don’t even care about the grid itself, you just want the vertices stored inside a matrix for quick access? There’s a line of code for that as well.

To see Grid Framework in action take a look at my introduction video:

Here are some of the key features in the current release:

  • a quick and simple drag&drop setup
  • a new fully scriptable grid component for you objects
  • convert coordinates from world space to grid space and vice-versa
  • find vertices and cells inside your grid
  • a built-in editor panel for scaling and aligning object to assist you in designing levels
  • or use those functions at runtime in your game, for example in a level editor
  • full scripting documentation and explantation of grid design concepts included
  • more features and more grid types planned, all updates for free

Tutorial Videos: (based on version 1.x, but most of the code is still valid)
grid-based randomized movement with limits

grid snapping during runtime
grid-based game logic in a puzzle game
How to extend Grid Framework with your own methods (continuation of the above)
level design and text parsing for building grid-based levels from plain text files
seemingly endless grid

For more information see the official website, take a look at my YouTube videos and visit my blog:
http://hiphish.github.io/grid-framework/
http://hiphish.github.io/grid-framework/news

By buying this package you will get all future updates for free, even as the price goes up, and support further development.

I am kinda sold :slight_smile:

Is this usable with Javascript?
Thanks

Of cource, the framework is written in C#, but unless you want to dig through my source code (which you can if you want to), just use the documented API, it works in any langueage. Once a script is compiled by Unity it doesn’t really matter what language it was written in.

BTW, the package has been submitted today, now I need to wait for approval.

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.

I look forward to this actually, allthough I’d like to know the API before I commit, although for the price I don’t really mind. Here are some suggestions by the way:

  1. A demo like a strategy game where you show how it’s possible to snap place things on the grid, while the grid return the front tile of the placed object tile for example.

  2. A VERY much simplified demo version of the old windows game minesweeper.

best

I can send you the documentation via PN, no problem. I wanted to do the stategy game thing, the snapping part is just one line, now I need to roll a quick method for dragging objects with the mouse. Minesweeper is a very good idea, I wouldn’t even need to simplify anything, but the problem is that the most elegant way to make such a game would be using Delegates and Events, which are C# territory. It’s really not much different from the lights-out example.

Hey,

I’d like to see the API if you don’t mind and can send. My suggestions were for showcasing your product. In my case, my game is a tile based one, so I tihnk your framework will come much in handy since I am a JSer and designer mostly, rather than a programmer.

OK, I made up my mind, I’ll include the movement example, the strategy example and the lights-out example. No point in a Minseweeper example as would be very similar to the way the lights-out example works. I finished the movement video, I’m currently rendering and uploading… EDIT:
http://www.youtube.com/watch?v=m9_efVi_tFs

I sent you a PM already.

I like this plugin. hiphish, do you sent me a beta version? I’ll test it. :wink:

could this be used to limit movement to diagonal? Something like Checkers for instance?

There is nothing left to test anymore, there is no Beta. All features work as supposed, it’s just the amount of features that will be increased with more grid types. Anyway, it sould be up in a day or two, depending on the Asset store team. I might do Beta releases with the new features though.

Sure. In the Lights Out example (included) I compare grid coordinates to decide if two tiles are adjacent. Here is a rough idea of how to do it:

var thisTile: Vector3;
var otherTile: Vector3;

//diagonal on an adjacent tile
var isDiagonalAndAdjacent: boolean = Mathf.Abs(thisTile.x - thatTile.x) == 1  Mathf.Abs(thisTile.y - thatTile.y) == 1
//or if you just want it to be diagonal
var isDiagonal: boolean = Mathf.Abs(thisTile.x - thatTile.x) ==  Mathf.Abs(thisTile.y - thatTile.y);

(instead of ==1 you shuld do <=1.1 and >= 0.9 or something like that, use a range with a small tolerace instead of exact numbers because of floating point rounding errors. The engine might show you 1.0, but if the real values is 1.0000000001 the check will fail, so you need a certain tolerance. That’s just how float numbers work)

What this example does is compare if both the X and Y coordinates are one unit apart (the Mathf.Abs means it doesn’t matter if the coordinate is left or right), which is the case if and only if two tiles are diagonal to each other. Both coordinates are in grid space, which you can easily covert to and back using

var myGrid: Grid;
var newVector: Vector3 = myGrid.WorldToGrid(oldVector);
// do some stuff and return the value in world space
return myGrid.GridToWorld(newVector);

It has been approved! Here is the download link:

Aside from the relevant scripts you get the documentation, three demo scenes (coded in JavaScript and C#, exentsively commented), a debug prefab and the editor panel. If you have questions or suggestions feel free to post them here :slight_smile: I’m looking forwardto your comemnts.

Nice :slight_smile:

Congrats, this is a great idea. We have a heavily grid-based game in development so we’ll definitely be grabbing a copy of this to help with level building!

I’d pay $20.

Another video tutorial, howing how to use grid-based game logic in a puzzle game. This is the tutorial for the lights-out game I mentioned before and which has been included with the package.

https://www.youtube.com/watch?v=sXlagrglfQ8

This tutorial is written in C# because it uses delegates and events. The reason why is so that no single tile needs to know about the other tiles, making this code extremely flexible, you culd even change your scene during runtime. If you don’t know about delegates and events I really recommend you to check out prime31studios’ video. Their video series really got me into C# development.
http://www.youtube.com/watch?v=N2zdwKIsXJs
To give you the basic idea, events and delegates mean that somewhere somehow something happens and some other objects react to that. The object that triggered the event itself has no idea who (if anyone) is listening and how they will resond. For example you could have an RPG where when you draw your sword it makes villagers run away and guards draw their own weapons. Your hero would not need to know how many villagers and guards (if any) are around, he just needs to fire the event and all listeners will react accordingly.

Nice to hear that :slight_smile:

Three updates! (also new screenshots in the asset store)

Version 1.0.1 has been approved
If you tried debugging the functions FindNearestFace() or FindNearestBox() you might have noticed that the cubes drawn didn’t have the same rotation as the grid. While it didn’t change anything about the returned value (only the centre of the cube mattered), it looked ugly. I’ve submitted a small update that fixes the rotation:

Grid Rendering Progress
I’ve started tackeling grid rendering and it’s ready to use. It’s still not ready to ship though, I need to do some good code cleanup since I just copy-pasted code from another function, and copy-pasting code is very bad practice. During the cleanup I came across an issue, which required me to redisign two classes of mine, which in return required me to write my own custom inspector…

New RectGrid Inspector
I wanted to do this sooner or later anyway, but I had no choice but to do it now. The problem is that the default inspector cannot display getters and setters, so I could have either waste time trying to find some workaround which might or might not exist, or I just simply write my own inspector:


It’s much cleaner now and makes more sense.

Unity just approved version 1.1.0, which includes the new inspector panel and the rendering setup. Now you can see your grid in the finished game, no pro license or any other addon needed.

Version 1.1.1 has been approved, it lets you set the width of the rendered line in the inspector. Here is an example, obviously it’s over the top, but you can set the width to anything you like.

Now I just need to provide a nice function to pass rendering points to Vectrosity. I’m sure those of you who own a Vectrosity license would like to be able to combine the best of both. I promise when I’m done it will be the last time you’ll see me talk about rendering for a while.

Hi,

I installed 1.1.1 and got this error:

“Assets/Plugins/Grid Framework/Grid.cs(73,17): error CS0103: The name `GridRenderManager’ does not exist in the current context”

[EDIT] Never mind…, I found the problem. I had to manually move your files to the plugins and editor folders, so the update had to be manually fixed as well. It would be great if you could group your files so they are installed to the official folders automatically, e.g.:

Assets
  Plugins
    Grid Framework
         ...

  Editor
    Grid Framework
        ....
  Grid Framework    # <-- extras, easy to delete
      docs, examples, etc

Are you sure you had to move the editor files as well? They always worked from where they were for me. i also have other people’s editor extensions and didn’t have to put them into the global editor folder.

Anyway, I’m afraid I cannot do what you suggested, the Asset Store allows me only to upload one single folder. When I export a Unity Asset package I can combine folders as I want, no problem, but for the asset store everything has be be in the same folder. It is really annoying, but you have to do the same thing for iTween for example as well.