Search Unity

How to make UI and gameobjects work together?

Discussion in 'Getting Started' started by Xinzz, Mar 8, 2016.

  1. Xinzz

    Xinzz

    Joined:
    Jun 28, 2015
    Posts:
    67
    Hey guys. I'm trying to make some kind of 'puzzle game'.

    But i got stuck on how to make things work together, For example:



    1.drag 'left arrow' or 'right arrow' or '1','0' from Area 1, and drop to Area 2.
    2.press 'play' button, and game object will execute operations that in Area 2 in order.
    left arrow -- game object move left 1 ---- one of cell in game object was set to 1
    right arrow - game object move right 0 ---- one of cell in game object was set to 0

    I'm not sure i make it clear to you guys, and It should be simple but i have no clue how to do it right now, anybody could recommend some tutorials or ways to do it? Thanks!!
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I get what you're trying to do. It's something like Light Bot, but (from your drawing) it looks more like you're programming a Turing Machine.

    So, this is a pretty advanced project. But I'm sure you can handle it if you can break it down into parts:
    • make UI objects you can drag around
    • make a "well" or source of UI objects that, when you click 'em, creates a new one for you to drag
    • make a "drop target" UI area that accepts dragged objects and snaps them to a proper position
    • make dragged UI objects disappear if dropped anywhere other than on a drop target
    Note that when you get to this point, you'll have your basic UI for defining the program. Now you need to execute it! Again break the problem into smaller, bite-sized chunks:
    • print out (with Debug.Log) the items in the drop targets, in order
    • write code to do each of the operations (move left, move right, write 0, write 1)
      • oops, to do that you need a model of the tape, with 1s and 0s on it
    • execute each of the items in the drop targets, waiting until each operation is done before doing the next
    It's all quite a bit of work, but if you take it one step at a time you'll get there, or at least level up your skills a bit!
     
    Xinzz and MikeTeavee like this.
  3. Xinzz

    Xinzz

    Joined:
    Jun 28, 2015
    Posts:
    67
    Ye
    YES!! It is a turing machine!

    The UI parts i'm kind of figure it out, And now what i'm trying to figure out is how i'm gonna know what 'drop target' have, and how am i gonna do something with it. Means make the UI connect to game object, should i do it through name or something, still thinking.

    And thanks for your reply!
     
  4. MikeTeavee

    MikeTeavee

    Joined:
    May 22, 2015
    Posts:
    194
    I really liked this.

    ..."Level up your skills a bit"

    It inspired me to go and learn something new today.
     
    Xinzz and JoeStrout like this.
  5. Xinzz

    Xinzz

    Joined:
    Jun 28, 2015
    Posts:
    67
    Thanks to Joe, I'm at final step now. :)

    Edit:I've finished it, kind of like a demo.
     
    Last edited: Mar 11, 2016
    JoeStrout and MikeTeavee like this.
  6. Deleted User

    Deleted User

    Guest

    gee whiz there goes an hour
     
    JoeStrout likes this.