Search Unity

Turn-based, square-grid strategy game help

Discussion in 'Getting Started' started by TNoakes, Jul 29, 2015.

  1. TNoakes

    TNoakes

    Joined:
    Jul 29, 2015
    Posts:
    3
    Hi everyone, I've been looking at tutorials for ages but I'm not sure what to follow

    I would like to create a grid-based, turn-based strategy game where the grid isn't apparent, so the lines aren't drawn but it should be pretty obvious that there is a grid that is allowing movement.

    I have followed this:



    But am not sure if there is another way where I could just draw a grid onto a plane rather than use loads of cubes?

    Any help on anything would be good. I have a bit of experience in modelling and texturing and a bit of messing around in Unity, but not much more.

    Cheers!

    Tom.
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    I'm currently making a chess-like board game that has a checkered board. Each square is its own object, which is just a single quad. I considered trying to optimize it to a single plane across the board, but doing them as separate objects has its advantages:
    • If your game requires clicks at certain locations, it's much easier to detect where the user is clicking if they're separate objects. Otherwise you have to do calculations on the plane and that gets trickier. Separate is easier, trust me. I do recommend planes instead of cubes, though, unless you want a 3d space that resembles Minecraft
    • You can actually store data in a way that makes more sense this way, too. In my case, each square tile keeps track of information such as whether or not it's currently occupied, whether or not it's the edge of the board, etc.
    • If you're building your field at runtime (like I am with the game board), it's much easier to debug and see what's happening with separate objects.
    What reason do you have for not wanting to use separate objects?
     
  3. TNoakes

    TNoakes

    Joined:
    Jul 29, 2015
    Posts:
    3
    I just thought it may be easier to do it that way, and not so system intensive.

    Thankyou for the convincing argument! I have decided to create a simple 'board' in Blender, which I will then 'carve up' into different shapes to represent different city districts, we'll see how it goes!

    Tom.
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Just to provide another perspective, I'm wrapping up a grid-based game now, and I have a single object that represents the whole board. I sized things so that 1 unit of Unity space equals 1 square on the grid. When I detect a click or drop a piece or whatever, I use this fact to easily find the grid position indicated. Conversely, when I want to put something at a specific grid position, I just use that as the transform position, and Bob's my uncle.

    I have another game or two that uses a hex grid; in this case it's a little more complicated. You have to go through some math to convert between grid positions and world positions, or vice versa. I wrapped that all up in a couple of classes so that, having figured it out once, I wouldn't have to think about it any more.

    To @TNoakes, you must separate in your mind the drawing of the grid from the mathematics of the grid. It doesn't matter whether you draw your grid as a texture on a plane, or a bunch of cubes, or a series of kittens, or don't draw it at all. The grid is a mathematical construct... so the question you should be asking yourself is, what exactly do I need to do with this grid? And then pursue the how-to for each such thing you need to do.
     
    Schneider21 likes this.
  5. TNoakes

    TNoakes

    Joined:
    Jul 29, 2015
    Posts:
    3
    To @JoeStrout , thanks for the information, would it be worth creating the map before bringing the mathematical grid into it? As that is the part which I am most familiar with. Or do you reckon I should figure out the maths first?

    Cheers

    Tom
     
  6. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    If you're more familiar with creating the design of it, then DEFINITELY do the math first. Better to ensure that whatever you design will fit the constraints of your system, than to have to build a system that perfectly accommodates your design, if you ask me.

    @JoeStrout I'm starting to question the decisions I've made now. :p If I get through this project and ever tackle another tile-based game, I"ll be picking your brain for a bit more detail.
     
  7. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I agree, you're probably better defining the math first. I would start with the two most basic operations:
    • Find the world position for any grid position (test this by sticking a few objects on the grid!)
    • Find the grid position at any world position (test this by continuously displaying the grid position the mouse is over)
    Once you've got these, then you can apply it to actually build out your design!

    @Schneider21, there's always more than one way to skin a cat. Your mileage may vary, never eat spinach with a stranger, etc. But I'm happy to share my experience in more detail if you ever need it!
     
    vyshan likes this.