Build a Chess Game
Learn how to create a chess game in Unity using Coplay
This guide will walk you through the process of setting up the game board, creating chess pieces, and implementing basic game logic, including an AI opponent that can play against you.
Prerequisites
To go through this tutorial, you should have the following:
- A new Unity project with Coplay installed.
When making a new project, make sure to select the 3D Built-In Render Pipeline template as this tutorial uses assets build with that rendering pipeline. This is required for the chess assets you’ll be using. You can use the HDRP or URP templates, but you will need to adjust the materials and shaders accordingly.
- If you haven’t installed Coplay yet, follow the installation guide
- A Unity Asset Store with this free chess asset pack added (trust us, it’s easier than creating your own chess pieces):
Configure your Coplay settings
- Open the Coplay settings window by going to Coplay > Toggle Window in
the Unity menu or pressing
⌘ + G
orCTRL + G
depending on whether you’re on Mac or PC. - Make sure the Auto-approve option is checked.
- Set the Model to
claude-4-sonnet
(feel free to play around with other models — we have generally found the best performance with this one).
Import Your Chess Assets
- Download the chess asset pack from the Unity Asset Store.
- Navigate to
Window > My Assets
and import the downloaded package into your Unity project. - You should now see a folder named
Chess Pieces
in your project window.
Make sure to uncheck the Blender.zip
and Chess Demo.Unity
files when importing the package,
as they are not needed for this tutorial.
Write a prompt telling Coplay what to do
This is the fun part. Use the prompt below as a starting point but feel free to modify it to your liking once you have a working game.
This prompt is going to change the following:
- Each game piece controlling possible actions
- A game manager that initializes the board with appropriate layout and manages game state
- Mouse input controller using Unity’s Input System with raycast detection for piece selection,
- AI opponent with minimax algorithm and adjustable difficulty levels.
Run the prompt
- Copy the prompt above and paste it into the Coplay chat window.
- Press
Enter
to send the prompt to Coplay. - Wait for Coplay to process the request and generate your chess game.
Go get a coffee
You’ve earned it. Coplay’s got it from here.
Check in on Coplay's progress
- After a few minutes, check the Coplay chat window to see the progress of the chess game creation.
- Coplay will provide updates on the game setup but will stop every 20 actions to ask for your approval. This is expected and default behavior to ensure you have control over the changes being made to your project.
- If Coplay asks for approval just click the Approve button to continue.
- If you want to make changes to the game, you can stop Coplay
by pressing
Shift + ⌫
or clicking theStop Thinking
button in the Coplay chat window.
Play the Game
- Once Coplay has finished creating the chess game, you can play it by clicking the Play button in the Unity Editor.
- Follow the on-screen instructions to start playing against the AI opponent.
- If you want to change the AI difficulty, you can do
so by modifying the AI script in the
Assets/Chess Pieces/Scripts
folder.
Share Your Game with Us!
We would love to see what you have created! Share your chess game with us on social media and tag us! Even better, share it in the Coplay Discord community.
Take Your Game to the Next Level!
Now that you have a basic chess game, consider enhancing it with additional features: