Chess App Workshop 1 Tutorial
Chess App Workshop 1 Tutorial
Workshop 1
Prerequisites
-Unity installed (preferably version 2019.3 or newer)
-An IDE (code editor) that is attached to Unity
-When installing Unity also install Visual Studio with it for it to work automatically
-The completed version: https://github.umn.edu/app-developers-club/Chess_App
● Select a sprite such as “black_king” and drag it into the “Sprite” section of the sprite
renderer
● Again, set the scale for this object (the X and Y) to 3
● Open the Objects folder
● On the left tab, drag “Chesspiece” down to the “Objects” folder
● This has created a prefab for us to use
● Now delete the object from the left tab, which will remove it from the screen
○ We will spawn these chess pieces in ourselves through code, trust me it will be
easier than setting the positions one by one
Create a controller:
● This is the most important object for this and most games!!!!
● Navigate to “GameObject” from the top drop down menu and create another empty
object
● Rename it to “Controller”
● Drag it above “Main Camera” in the Hierarchy menu as it is the most important
GameObject
Spawn the Chesspiece:
● Navigate back to “Assets” and create a “Scripts” folder
● Click on the folder
● Right click and create a “C# Script”
○ C# is the programming language used by Unity
○ Don’t worry if you have never programmed with it as it is similar to Java
● Rename this script to “Game”
○ Make sure the Class in the code itself is the same name
● Click on the controller asset
● Drag the “Game” script into the controller
● Double click on the “Game” script
● It should now be open with either Visual Studio Code or an IDE that you commonly use
● Inside here there are already Start() and Update() functions
○ Start(): run once at the Start of the game
○ Update(): run every frame
○ There are many more built-in functions provided by Unity and of course you can
create your own
● Delete the Update() function
● Above the Start() function type the following code: