Gamelogic
  • Home
  • Blog
  • Tools
    • Grids 2 (for Unity)
      • Features
      • Documentation
    • Grids 1 (Legacy, for Unity)
      • 30 games in 30 days
      • Features
      • Tutorials, Documentation, and FAQ
      • Games made with Grids for Unity
      • Examples
      • What is new?
      • Grid Prototypes and Previews
      • Buy
    • Extensions
    • Colors
      • Features
      • Documentation and tutorials
      • Buy
    • Words
      • Features
      • Documentation
      • Buy
    • Abstract Strategy
      • Features
      • Documentation and tutorials
      • Examples
      • Buy
    • Match
      • Features
    • Grids (for GameMaker)
      • 30 games in 30 days
      • Features
      • Documentation
      • Buy
  • Buy
  • Articles
  • Support
    • Knowledge Base
    • Email Support
  • About
    • Meet our team

Creating your own pieces

OwnPieces

This tutorial will show you how to create your own pieces. We will use the following board,

OwnPieces1

with these rules:

  • One turn per player.
  • Al blue ones moves first, then red.
  • You can move anywhere.
  • You can’t capture enemy pieces.
  • You can’t win or lose.
1Make a new empty GameObject. Add a SpriteRenderer, and set the sprite to whatever image you want. Add a GridGamePiece component. Finally, you make this GameObject a prefab.

OwnPieces2

 

2Create another empty GameObject, and give it the same name as the piece created in the previous step with  _Logic or _Setting added so that you know they are related.  Add a Grid Game Piece Setting component, and fill in the settings. For these examples all pieces have an Id of “piece” (they will have the same rules), and there is one player for each color and shape. Set the piece prefab to the prefab you made in the previous step.

Add a Open Space Move Rule component so that players can move pieces to any open position on the board.

OwnPieces3

Make this GameObject a Prefab too.

You can also add more piece rules. The default ones can be found by clicking on Add Component and then Gamelogic|Stragegy|Piece Rules. You can also create your own piece rules.

3To add the piece to the board, you need to configure two components on the GameBoard. On the Grid Game Rules component, add all the logical piece prefabs to the Pieces field in any order you want.

OwnPieces4

On the GridGameManager, add the pieces as you want to position them on the grid in the initial configuration.

OwnPieces5

Remember that the Piece ID and the Player ID are set on the *_Logical prefab of the piece.

—

To check out this example:

  1. Import Abstract Strategy in a new project.
  2. Import the package below into the same project.
  3. Open the YourOwnPieces scene.

YourOwnPieces.unitypackage

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Related

  1. Creating your own piece rules  In this tutorial we will look at how to implement special rules...
  2. Creating your own victory rules  On this tutorial we will cover how to create a...
  3. Moving a piece and changing turns  Setup a game board with pieces as explained in this...
  4. Setting up a grid and board  (To Learn more about Grids, see the documentation page for...

  • Setting up a grid and board
  • Moving a piece and changing turns
  • Using victory conditions
  • Animating a piece in the board
  • Home
  • Features
  • Blog
  • About
  • 14 Eglin Road, Sunninghill, Johannesburg, South Africa
  • support@gamelogic.co.za
Stay Connected
  • Facebook
  • Google
  • Linkedin
  • Rss
  • Twitter
  • Gamelogic © 2013