How to Create a Twitch Chat Game with Unity

Learn to integrate the Twitch Chat API into your Unity game, so viewers can interact with the game during streaming. By Harrison Hutcheon.

4.7 (3) · 3 Reviews

Download materials
Save for later
Share
You are currently viewing page 6 of 6 of this article. Click here to view the first page.

Using What You've Learned

You have the foundation and the know-how to create Twitch Chat games! Time to test those newfound skills.

There's another scene in the project called Golf. Use what you learned with Battle to turn it into a functional game!

Need help? Just open the spoiler below to find out how.

[spoiler title="Golf Game Requirements"]
Golf has the following requirements:

  • A GameManager keeps track of players and can retrieve a player by username.
  • Include a join command so audience members can join the game.
  • When an audience member joins, spawn a golf ball for them in a random color with their twitch username displayed above the ball.
  • Include commands to let a player:
    • Set the direction of their ball.
    • Set the power of their stroke.
    • Launch their ball in the specified direction, at the specified power.
  • A Game Over Check checks if all players have reached the hole.
  • A Game Over Action disables commands and displays a scoreboard with the players listed from highest score to lowest score.
  • A New Game Action resets the course and lets audience members submit commands.
  • Set the direction of their ball.
  • Set the power of their stroke.
  • Launch their ball in the specified direction, at the specified power.

See the following GIFs for an idea of what these features look like:

A player joining a Golf game

A Golf player setting the direction of their ball

A Golf player setting the power of their ball

A Golf player launching their ball

If you get stuck while working on Golf, check out the completed version in the Final assets to see some solutions.
[/spoiler]

Where to Go From Here?

Use the Download Materials button at the top and bottom of this tutorial to download both the starter and final projects. You can use the final project to compare with your own work.

In this tutorial you learned how to read messages from Twitch chat, and how to use them to interact with your game. Or two games if you did the bonus Golf game too!

Check out Introduction to Multiplayer Games With Unity and Photon to learn more about creating multiplayer games with Unity.

And while you are hanging out on Twitch, don't forget to follow Unity Tech for live streams of Made With Unity games and developer showcases. :]

I hope you enjoyed this article. If you have any questions or comments, please join the forum discussion below. See you in the next one!