Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Grid Framework [scripting and editor plugins]

Discussion in 'Assets and Asset Store' started by hiphish, Jul 24, 2012.

  1. Maxii

    Maxii

    Joined:
    May 28, 2012
    Posts:
    43
    Hiphish,

    Thanks for fixing the Unity 5.4 data_path error.

    I just downloaded the change 2.1.1 into a project that contains GridFramework and Vectrosity 5.3. After adding GRID_FRAMEWORK_VECTROSITY to scripting define symbols in ProjectSettings > Player, I am now getting the following error for all 3 of your renderers when I try to run your Vectrosity example scene.

    IndexOutOfRangeException: Array index is out of range.
    GridFramework.Renderers.Rectangular.Parallelepiped.CountLines () (at Assets/Plugins/GridFramework/Renderers/Rectangular/Parallelepiped.cs:59)
    GridFramework.Renderers.GridRenderer.UpdatePoints () (at Assets/Plugins/GridFramework/Renderers/GridRenderer.cs:278)
    GridFramework.Renderers.GridRenderer.Awake () (at Assets/Plugins/GridFramework/Renderers/GridRenderer.cs:439)
    UnityEditor.DockArea:OnGUI()

    Your non-vectrosity example scenes seem to run fine.
     
  2. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    This is a weird one. It seems related to how Unity serialises objects: if I remove the renderer and the script and then add them back to the object it works fine, even if I didn't change a line of code. Unity must be serialising the renderer in a state where the array does not exist with the wrong size.

    This might take a while to narror down for certain, but I think making the offending member field non-serialised should do the trick. If you want to try it for yourself: In the file Plugins/GridFramework/Renderers/GridRenderer.cs delete line 86 so it looks like this:
    Code (csharp):
    1. /// <summary>
    2. ///  Amount of draw points.
    3. /// </summary>
    4. /// <remarks>
    5. /// <para>
    6. ///  Each of the three entries stands for the amount of *lines* to
    7. ///  draw per corresponding axis. You need to mutate this member in
    8. ///  <c>CountLines</c>.
    9. /// </para>
    10. /// </remarks>
    11. protected int[] _lineCount = {0, 0, 0};
     
  3. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    After some more testing it turns out that serialisation was indeed the issue. I have submitted a new version, the one-line fix will bridge you over in the meantime until it gets approved.
     
  4. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    Pretty examples
     
  5. True29

    True29

    Joined:
    Jun 27, 2013
    Posts:
    20
    i cant find the help file , can you sent me the help file pls ? email is happ17 (a) web.de thx.
     
  6. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    Something went wrong with the last update, a new one has been submitted and is currently waiting for approval. Here is a link in the meantime, extract the ZIP under Plugins/GridFramework/

    [Link removed, update has been published]
     
    Last edited: Mar 17, 2017
  7. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    Grid Framework version 2.1.4 released
     
    wetcircuit likes this.
  8. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    200
    Hi there! I'm just wondering whether it's possible to make an isometric 2d pixel grid in the X/Y axis with your asset? You can see what I'm after with the below images:

    [​IMG]

    [​IMG]
    So I want to create essentially a diamond grid in the X/Y axis, for a 2d grid-based game. But the idea is that down the road I can add a 3d free-camera option, as the underlying game engine is decoupled from the graphics and interface. The game is a square grid, but I want to use it with diamond pixel grid sprites.

    I hope that makes sense! And was wondering whether this is possible using your asset? Additionally does your asset contain things like range finding and weighted pathfinding?

    Thanks in advance for any help!
     
  9. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    Hello
    Yes, you create a "rectangular" grid and adjust the spacing and shearing values accordingly, for example to a spacing of (2, 1) and a shearing of (-0.5, 2) to get a grid like in this image:
    [​IMG]
    The term "rectangular" is a bit misleading since the grid can have sharing that makes it no longer rectangular, but that's a leftover from the early days before shearing was implemented. The grid coordinate system is still the same though, the shearing rotates the basis vectors in the world, but when scripting the grid-coordinate system is still "rectangular".

    I don't know what you mean by range finding? Do you want the distance of two positions in grid coordinates? That's simple:
    Code (csharp):
    1. Vector3 alice, bob;  // world coordinates
    2. RectGrid grid;
    3. var distance = grid.WorldToGrid(alice) - grid.WorldToGrid(bob);
    Pathfinding is not included. I was entertaining the idea for a while, but I concluded that pathfinding is too specific, there are many ways to do pathfinding, and if I picked One True Way™ it would only be useful to a subset of users and frustrating to everyone else. The guiding design principle of Grid Framework has always been to provide a library that you can adapt to your game instead of having to adapt your game to it. This means it's not a "just add water" type of kit, but at the same time it offers you freedom and flexibility a kit could not offer. I hope this makes sense as an explanation.
     
  10. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    200
    It does, and thanks for the reply! By range finding I mean 'get a list of all tiles within 3 squares', but I assume as pathfinding isn't a part of the frame work, this wouldn't be either.

    It makes perfect sense keeping it slim, but I'm after a grid solution that can handle that stuff. Thanks very much for the response!
     
  11. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    There is no "tile" data structure, because again, what a "tile" is depends on the game. You can keep an array of your own "tile" type to keep track of your game's state:
    Code (csharp):
    1. int width = _gridRenderer.To.x;
    2. int height = _gridRenderer.To.y;
    3.  
    4. Tile[,] map = new Tile[width, height]();
    You decide what your tile class needs to store. If you have an object in the world you can get its tile-coordinates like this:
    Code (csharp):
    1. GameObject object;
    2. int x = grid.WorldToGrid(object.transform.position).x;
    3. int y = grid.WorldToGrid(object.transform.position).y;
    And now you can use x and y as an index into your map array. Range finding can be done using .Net Linq queries, so you don't even need any extra frameworks for that.

    EDIT:
    It isn't even about being slim, it is about being general. With a kit what happens is that the developer has envisioned a certain way to write your game. This is great if that is exactly how you want your game to work, but if it is not you end up having to fight kit's own quirks, which defeats the whole point. I designed my plugin to be flexible, so you can integrate it into your code the way you want. Users can create their own extension methods, renderers, and even entirely new grid types. This isn't just theory, one user did in face create a guitar grid that resembles the way the strings and frets are arranged on a real guitar, something the included grids cannot do.
     
    Last edited: Mar 26, 2017
  12. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    200
    Sure. Being general, slim, whatever the motivation, different frameworks serve different purposes. Of course you could take the above to its logical conclusion, and say that a deeply opinionated developer should code everything from scratch, so it's all exactly how they want it! I personally try to find a balance, where I can benefit from others' frameworks, utilising their APIs to handle 'busy work', while being in charge of the overall architecture and implementation.

    You can include things like path and range finding in semi-generic ways, using callback functions to handle cell cost calculations etc. You can still have a user generated 'cell', and the path/range finding is simply the relationship between cells and their neighbours, little is opinionated, they're more like helper functions for common grid relationship behaviour. And you can make those functions completely optional. That's how Grids 2 operates, however while it's incredibly flexible, some of that flexibility has resulted in it becoming frustratingly obfuscated. So I'm on the hunt for a slightly less generic implementation, hehe.

    You're of course right that you can never guarantee more specific functions suit exactly the purpose or implementation that a developer requires, and if its your goal for your asset to remain general, that's perfectly fine!
     
  13. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    That is the idea behind Grid Framework, it's just that different people have different needs for granularity. I am always open for suggestions, what would your idea of a general pathfinding support be? I am not telling you to hold your breath for it instead of buying another asset, but I still think that opinions from non-customers are also valuable.
     
  14. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    200
    Well general pathfinding to me is being able to say "give me the cheapest path to get from cellA to cellB", a callback function would allow me to determine the movement cost between cells. e.g.:

    Code (CSharp):
    1. int GetCellMovementCost(cell1, cell2) {
    2.     return cell1.height < cell2.height ? 2 : 1;
    3. }
    I'd say indicating whether diagonal movement is allowed would be useful as well. But I am thinking solely from a square/rectangle-centric position.

    And you could employ similar behaviour for range finding. Though range finding gets more complex because you potentially start dealing with line of sight. However the two go hand in hand for my requirements, I'm looking for a solution to handle all things grid and grid movement.

    I agree entirely that different people have different needs, and it makes perfect sense that your asset's purpose is to just handle the former!
     
  15. jrDev

    jrDev

    Joined:
    Nov 5, 2008
    Posts:
    1,557
    Hello hiphash,

    I am looking into purchasing this package to use in a project to build a block puzzle stacking game (Pokemon puzzle league, Puyo-puyo etc) and I am planning to use Playmaker. Would this be a good package to get my project going? What will and what won't this package help me with? Looking forward to response.

    Thanks,
    jrDev
     
  16. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    Hello jrDev,

    Grid Framework can help you translate from grid- to world coordinates and vice-versa. You could keep track of your game's state in an array like this:
    Code (csharp):
    1. // Cell is some custom type representing the state of one field
    2. Cell[width, height] gameState;
    3. // Translate the position (i, j) of a field in the matrix to a world position:
    4. RectGrid grid;
    5. var position = grid.GridToWorld(new Vector3(i, j, 0));
    With this you can write all your logic in grid coordinates and let Grid Framework translate an entry in the state array to a world position for placing your game pieces in the world. Here is an idea:
    Code (csharp):
    1. void SpawnTile(int i, int j, Cell tile) {
    2.     gameState[i, j] = tile;
    3.     SpawnSprite(tile.sprite, grid.GridToWorld(new Vector3(i, j, 0)));
    4. }
    5. void MoveTileDown(int i, int j) {
    6.     gameState[i, j +1] = gameState[i, j];
    7.     gameState[i, j] = null;
    8.     MoveSprite(-grid.Up);
    9. }
    As you can see the functions that implement the tile movement don't know anything about the world, and the (hypothetical) functions that implement sprite movement don't know anything about the game's rules.

    How the game is supposed to work is up to you. Grid Framework does not make any assumptions about the game itself, so it is completely up to you what the "Cell" type actually is and how to build that array (assuming you even want to use one). Grids are not some finite collection of points, they are grid in a mathematical sense (infinite in size, constant memory use).

    This is at least what I can think of for such a type of game. If you have any more concrete questions let me know.
     
  17. dre788

    dre788

    Joined:
    Feb 15, 2013
    Posts:
    35
    Hello, I recently updated to 2017.2 beta and I got this error.
    Code (CSharp):
    1. Assets/Plugins/GridFramework/PlayMaker Actions/FsmGFStateAction.cs(19,29): error CS0104: `Grid' is an ambiguous reference between `UnityEngine.Grid' and `GridFramework.Grids.Grid'
    2.  
    There was a folder called "Test" where a file was giving me the same error but I deleted it. Is there anything on my end I can do to fix this?

    Thanks for the great asset and thanks for your time.
     
  18. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    Hello,

    Looks like Unity is adding their own grid components and the two names are colliding. Can you please try the following: in the file Assets/Plugins/GridFramework/PlayMaker Actions/FsmGFStateAction.cs add the following line:
    Code (csharp):
    1. using GFGrid = GridFramework.Grids.Grid;
    after
    Code (csharp):
    1. using GridFramework.Grids;
    and then change any occurrence of Grid to GFGrid. The extra line solves the naming conflict by aliasing one of the classes to another name.
     
  19. dre788

    dre788

    Joined:
    Feb 15, 2013
    Posts:
    35
    Excellent, that seems to have done the trick. Thanks for the speedy rely. You rock! Now I need to get playmaker itself to act right.
     
  20. jovalent

    jovalent

    Joined:
    May 27, 2017
    Posts:
    4
    Is there going to be a new version for Unity 2017? If so, when and will it be a free or a paid upgrade?
     
  21. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    Yes, I'll get to it today, I just finished another project a few hours ago. The fix is a simple search&replace as outlined in the post above yours, but I cannot tell you when the update will be approved by the Asset Store team, so please use the fix above until then. The update will be free of course, a compatibility fix is not worth paying for, I'm not that greedy :)
     
    jovalent likes this.
  22. jovalent

    jovalent

    Joined:
    May 27, 2017
    Posts:
    4
    Really I was asking because I want to buy this product but not if I'm going to have to upgrade in a month.
     
  23. hiphish

    hiphish

    Joined:
    Nov 13, 2010
    Posts:
    548
    I don't have plans for a major update at the moment, so no paid updated for the foreseeable future. The problem outlined above only happens if you want to use the Playmaker actions, for everyone else the current version works fine.