Chapter 10. Engaging With Users Using Twitch
In the previous chapter, we explored AWS with a specific look at Cloud Canvas and Amazon S3 for cloud computing and storage respectively. Our exploration included an overview of the need for cloud-based solutions to enhance Lumberyard games. Using a hands-on approach, we used the AWS Console to create an Identity and Access Management (IAM) user. We also employed the Cloud Canvas Gem and learned how to access Amazon S3.
In this chapter, we will take a singular look at Twitch, the Amazon Web Service that allows people to watch live game streaming. You will also learn how to implement Twitch functionality for in-game user interactions. Key concepts will include Twitch JoinIn and Twitch ChatPlay.
After reading this chapter, you will:
Understand the concept of video game broadcasting
Understand the components of Twitch
Have your own Twitch account and Broadcast Channel
Be able to instantiate Twitch ChatPlay in a Lumberyard game
Be able to use Twitch JoinIn...
A twitch is defined as a sudden movement or jerk. The Twitch that we care about is a noun, not a verb. Twitch launched in 2011 as an online video gaming broadcast network. The online service joins gamers and game enthusiasts for live and recorded events. Uses for the service include broadcasting your games, watching live game streams, watching recorded videos of previous gameplay, and engaging in chat. The site's monumental growth in popularity is one of the aspects that led Amazon to purchase Twitch. This is a bonus for Lumberyard developers because Twitch and Lumberyard are compatible.
Video games are often played with some sort of social component. A classic example of this is playing a first person shooter console game with headsets that allow you to communicate with your team. Many online games support in-game text chat. While some might see this as a distraction, the industry has seen social components of games steadily increasing. Twitch takes this to another level...
It might seem like integrating Twitch in our Lumberyard games is a simplistic task. After all, we simply want to enable Twitch or not enable Twitch, right? There is a lot that goes on behind the scenes that we, as game developers, must contend with to enable Twitch in our games.
In this section, we will consider what is possible with Twitch and look at the components necessary to fully integrate with Twitch: Twitch ChatPlay, Twitch JoinIn, and the Twitch API.
You can think of Twitch in two ways. First, there is the service that is accessible at https://www.twitch.tv/. Although this service is owned by Amazon, it is where the end result of our efforts lies and is therefore not our focus. The second way to think of Twitch is as a set of tools and APIs to enable real-time socialization of our Lumberyard games.
What is possible with Twitch?
By now you know that we can set our games to stream on Twitch and enable chat. What are the capabilities of Twitch besides streaming games...
Implementing the Twitch ChatPlay system
Twitch ChatPlay is a framework used by Lumberyard to implement Twitch connectivity and functionality. To demonstrate its use, we will first create a new game level. We will perform minor edits on the game level to include some terrain and the addition of 3D objects. Next, we will incorporate Twitch ChatPlay into our level. Finally, we will test our game. The steps to complete each of these three objectives are presented in the next three subsections.
Objective 1 - Creating a new game level
Before we can implement Twitch ChatPlay, we need a game to use. We could use a sample game level, such as one of those we have worked with in previous chapters. Instead, we will create a simple game level as the basis for our testing. Here are the steps:
Launch the Lumberyard Editor.
Click the New level button.
In the New level dialog window, enter a name for your level, such as TwitchTest
.
Click the OK button on the New Level dialog window.
The Generate Terrain Texture...
Understanding Twitch JoinIn
As you will recall from earlier in this chapter, when you integrate Twitch into your game you are considered a Twitch Broadcaster. You are broadcasting your game to your Twitch Channel for others to watch and, if so enabled, use Twitch ChatPlay to interact with your game. So, how do people know about your game on Twitch? How you advertise and announce your channel is up to you. If you want to target specific viewers in your game, you can use Twitch JoinIn.
Twitch JoinIn uses GameLift session information and a Flow Graph node to provide linkages between users and your game. We covered GameLift in Chapter 7, Creating Multiplayer Gameplay, and will discuss the appropriate Flow Graph node in this section.
Twitch JoinIn uses the Twitch:ChatPlay:Whisper and Twitch:JoinIn:CreateLink
Flow Graph nodes.
The Twitch:ChatPlay:Whisper node, shown here, is used to send game session information to your targeted viewers. The session information is sent via a link that can be clicked...
Twitching with the Twitch API
An API, or Application Programming Interface, is a set of software tools for creating applications that integrate with other software or services. In our context, the Twitch API defines how we can programmatically integrate our game with Twitch.
In Lumberyard, we can use the Twitch:API:GET Flow Graph node to make calls to the Twitch API. That node, shown below, has three inputs and two outputs. The inputs consist of the channel name, the specific API_Key, and Get to start the API call. The outputs are used for returned values and error handling.
Using the API, we can go beyond what is available to us using Lumberyard's Flow Graph Editor. The Twitch API and supporting documentation are available at https://github.com/justintv/Twitch-API.
In this chapter, we explored the use of Twitch and how to integrate Twitch with the games we create in Lumberyard. We started with a discussion on video game broadcasting and then explored Twitch as a service. We walked through the steps to create a Twitch account and a Broadcast Channel. Using a blank game level, we created 3D objects and used the Flow Graph Editor to instantiate Twitch ChatPlay. Our efforts resulted in a game that could be interacted with live chat on Twitch. We concluded our Twitch coverage with an overview of Twitch JoinIn and the Twitch API.
In the next chapter, we will look at how to wrap up your game and prepare it for distribution. We will explore several types of builds, including game builds, testing builds, debugging builds, and release builds. We will discuss methods of debugging, testing, releasing, and supporting your games.