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:
- Create a cube. Position it at
-2.8
,1
,-19.7
with a scale of4.2
,1
,4.2
. This puts the square in the top-left cell of the grid, sized appropriately. - Rename it
Square
. - Create a new Javascript and rename it
Square
. - Drag the
Square
script onto theSquare
GameObject. - 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.