Time for action – it's hip to be square

The way that players interact with a Tic Tac Toe is to place an X or an O piece in the empty spaces on the grid. If we create an invisible, clickable GameObject to sit in those spaces and respond to clicks, we'll have nailed down most of the game's interactivity. Follow these steps to create that clickable square:

  1. Create a cube. Position it at -2.8,1,-19.7 with a scale of 4.2,1,4.2. This puts the square in the top-left cell of the grid, sized appropriately.
    Time for action – it's hip to be square
  2. Rename it Square.
  3. Create a new Javascript and rename it Square.
  4. Drag the Square script onto the Square GameObject.
  5. Add this to the GameLogic script:
    function ...

Get Unity 4.x Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.