Make a text console game

Text console games are simpler than graphical ones and help you to learn fundamental C# programming concepts like data structures.

Create a text-only game using the Debug.Log console

The simplest possible game we can make in Unity is one that uses Debug console output and single keys as input.

  1. Make a new scene.
    1. Copy the code for Presser.cs from the pastebin link.
    2. In Project > Create > C# Script
    3. Name it Presser and hit return
    4. Open it in your code editor
    5. Paste the Presser code
    6. Save it
    7. In Unity, Hierarchy > Create > Create Empty
    8. Name it Presser and hit return
    9. Drag the Presser script onto the empty game object
    10. Save the scene, name it Presser
  2. Arrange your Editor to be able to see
    1. Make sure your Game view has focus
    2. Make sure you can see several lines of the Debug Console
    3. In Console panel, disable Collapse because we do not want to combine similar debug messages.
  3. Hit play to test the game
    1. Press RETURN to start the game timer
    2. Press SPACE 10 times as fast as you can
    3. Try to get the fastest time
  4. Hit STOP to end the game
  5. Hit PLAY again
    1. Notice that it saves our high scores from before and remembers them using PlayerPrefs

Presser 2 – The Sequel

  1. Duplicate the Presser script in the Project view
  2. Rename it Presser2
  3. Open it and rename the class at the top to Presser 2
  4. Save the script
  5. Create a new scene
  6. Create an empty game object
  7. Name it Presser2
  8. Drag the Presser2 script onto the object

Making a text console with input

Unity has an official tutorial series on making a full text adventure game with keyboard input.

https://learn.unity.com/tutorial/recorded-video-session-text-adventure-game-part-1

https://learn.unity.com/tutorial/recorded-video-session-text-adventure-game-part-2

 

 

 

 

Leave a comment