Set up the Scene
Drag theMadderManager and MadderControllerManager prefabs from Packages > Madder Starter Pack > Runtime > Prefabs
into your scene. These prefabs are Singleton classes and will persist across scene loads. These are the core components
of the Madder system and are required for Madder to work with your game.
If you do not see the
Madder Starter Pack folder or any other packages, they
may be hidden. Click the visibility button to toggle them on.
SampleGameManager, SamplePlayerManager, and
MadderControllerTest prefabs into your scene. These prefabs are examples of
how you might interact with the Madder system.
Here’s an example of what your scene hierarchy might look like:

For this tutorial, we have provided a sample
PlayerInput asset that has
pre-loaded input actions and bindings. If you are following this tutorial with
your own assets, see the Madder Controller
Usage for more information on how to
bind your input actions to the Madder Controller.Examining the Sample Scripts
Before we move on, let’s take a look at what each script is doing:SamplePlayerManager
SamplePlayerManager
SamplePlayerManager.cs
SamplePlayerManager class is responsible for creating and managing players in the unity scene. On Awake, we
subscribe to the onRegisterMadderController event in the MadderManager class. When
the Madder server signals that a new player has connected to the room code, the MadderManager will trigger this event,
and the SamplePlayerManager will create a new player in the scene.SamplePlayerManager.cs
PlayerInput object and assign it to
the player. When you create a new PlayerInput object, Unity automatically checks for available input devices and will
assign the Madder Controller to the player. See the Madder Controller class for more
information.SamplePlayerManager.cs
UnregisterPlayer method that removes a player from the scene. This method
is called when the Madder server signals that a player has left the game room.We also have a helper method called TryGetPlayerInput that allows other classes to access the PlayerInput object for
a given player, if needed.SamplePlayerManager.cs
Complete Sample Player Manager Class
Complete Sample Player Manager Class
SamplePlayerManager.cs
SampleGameManager
SampleGameManager
The SampleGameManager class exists in this sample to facilitate testing and simulating Madder controller inputs. The
SampleGameManager class finds the MadderControllerTest object in the scene, which sends inputs to the Madder Manager
as if they were coming from a player’s controller.SampleGameManager.cs
MadderControllerTest
MadderControllerTest
The MadderControllerTest simulates Madder controller inputs and sends it to the Madder Manager. The function
TestMadderInput registers a new Madder controller with a random name and sends a new controller state with different
values after 5 seconds.MadderControllerTest.cs