Search Unity

Help me figure out how to create my basic grid movement system (imgur album included)

Discussion in 'Getting Started' started by Jtylerg, Sep 28, 2015.

  1. Jtylerg

    Jtylerg

    Joined:
    May 20, 2015
    Posts:
    1
    Hello everyone! I am very new to Unity (less that two days experience) and have started playing around with a game idea that I have. In the game, I require a grid based movement system which I started on a bit, but have no clue how to script and execute. The only control needed is left-click or a screen tap if I decide to make it on a mobile platform... but just left-click for now.

    It's a very simple concept at this stage, but I just don't know what all I need to make this function properly.

    http://imgur.com/a/TzBDo

    ^^^
    Imgur album detailing exactly what I want done. I tried to be as clear as possible but if you need any extra information just ask. Thanks in advance for any help!
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Well, what's your background? I understand you're new to Unity, but have you done significant programming before? What about C#?

    Without knowing that, it's hard to know how to properly frame an answer. But I'll take a stab at sketching out the simplest solution I can think of, and we can take it from there.

    First, this looks 2D to me. So, forget about cubes; think sprites. (Run through some of Unity's 2D tutorials if you haven't already.)

    You will need a game board manager. This is a script that lives on an otherwise empty object in the scene, and which keeps a 2D array of sprites representing the contents of each cell. It will also need some easy way for other scripts to find it, perhaps using a Singleton pattern.

    When a game piece is clicked, you'll detect that using a script on that sprite object. It will notify the game manager that it was clicked. The game manager will note that that piece is now "selected" (by assigning its row and column to some properties you keep around for that purpose), and then walk its 2D array, finding the empty neighboring cells, and setting the "highlight" sprite image to each of those neighboring sprites.
     
  3. jhocking

    jhocking

    Joined:
    Nov 21, 2009
    Posts:
    814
    Yeah the appropriate thing for us to suggest varies a lot depending on your previous experience. If you don't already know how to program, we'd basically be giving advice about learning that. If however you do already know how to program, what joestrout said is pretty much correct. If you need help learning how Unity works, checkout my book Unity in Action.