Twitchmata is a library to help you integrate an Animata/VIPO stream overlay with Unity.
Twitchmata has been tested on Unity 2022.1+
Animata are a type of VTuber, virtual stream avatars common on Twitch. Animata are more akin to puppets, often controlled with a game controller, and they exist in a VIPO: Virtual Interactive Puppet Overlay. A VIPO is a virtual environment, often built in a game engine, which an Animata can move around in and interact with. They also provide interactivity to viewers, responding to various events on Twitch, which is where Twitchmata comes in.
For a great example of what a VIPO overlay can do, visit https://twitch.tv/doigswift
Twitch has various APIs to request information and get notified of events. There already exists an excellent implementation of this API in C# called TwitchLib. However, this API is designed to be generic and work for many different use-cases.
Twitchmata is a wrapper around TwitchLib to optimise the API for VIPOs and provide better Unity integration. It provides help for authenticating accounts and handles a lot of the boilerplate code so that you can focus on implementing what makes your stream unique.
Twitchmata currently has support for dealing with Follows, Subscribers, Raids, Bits, Chat (including Chat Commands), and Channel Points.
You can find out more about setting up Twitchmata in your overlay here
Twitchmata has a few key classes:
TwitchManageris the base class which acts as the root of the Twitch integration and is where you do most of the configurationConnectionManagerhandles the connection to Twitch through various API endpoint. You mostly don't need to touch this, but it lets you easily drop down to using TwitchLib directly if you need some functionality Twitchmata does not provide.UserManagerholds a list of users known to Twitchmata. Most APIs will give you aUsertype with information about who invoked itFeatureManagersare where most of your custom code will go. See below on how to use them.Utilitiesprovides additional functionality that doesn't fit in a FeatureManager (e.g. downloading a user's avatar as aTexture2D). (documentation)
Twitchmata provides access to various bits of Twitch functionality through Feature Managers. Feature Managers are intended to be subclassed by you to allow your overlay to respond to notifications or invoke various features. Below gives an example on how to set up a Feature Manager for handling follower:
-
Create a new C# Script in Unity called "MyFollowerManager" (or whatever name you desire) and open in your code editor of choice
-
Add
using Twitchmata;to the includes at the top of the file -
Change the super class from
MonoBehaviourtoFollowerManager -
Add an empty
GameObjectas a child of theTwitchManagerobject you added during setup -
Add the "MyFollowerManager" class as a component
Your MyFollowerManager class will now be notified when a user follows your channel and keep a list of everyone who followed while your overlay was open. Twitchmata provides Feature Managers for the following:
- Followers (documentation)
- Subscribers (documentation)
- Raids (documentation)
- Channel Points/Rewards (documentation)
- Chat Messages (documentation)
- Chat Participants (documentation)
- Bits (documentation)
Various parts of Twitchmata collect statistics during your stream. You can find out about the stats collected and how to access them in the Statistics documentation
Twitchmata provides various methods to help with debugging events. You more info in the Debugging documentation
Below are some common issues people can encounter while using Twitchmata
Make sure that you have the GameObject containing the TwitchManager script selected in your Hierarchy. Also check the window is not hidden behind another window or is on another screen.
Double-check you have copied the entire URL from your browser's address bar before pasting into the text field to save.
Also ensure that, in your application settings in the Twitch Developer Console, the URL is set to http://localhost:3000. Make sure there are no additional spaces, trailing /, etc
In most cases you can delete the version of Newtonsoft in Twitchmata's Plugins folder to fix this