Testing
On the SteamManager
inspector, there is an Auto Start
field which you can set to automatically start up your networking. Setting it to Host
will host a game, and Search
will automatically try to find a game, hosting if one is not found.
Testing multiplayer functionality with Steam can often be difficult due to being unable to start up two Unity instances on the same machine, as you can only be signed into one Steam account and playing one game instance at a time. Luckily, MPE4S has made testing your multiplayer code seamless, allowing you to test your game's networking with multiple players all on the same machine!
Simulated Networking
MPE4S replicates backend Steam lobby and networking functionalities, allowing you to spin up simulated local players who can play your game, read lobby data, set their own member data, and even send and receive chat messages!
To get set up with these simulated players, you will need to install either Multiplayer Play Mode or ParrelSync. Once you have chosen a tool to use with MPE4S, open up other player windows using that tool:
- Multiplayer Play Mode - From the top menu, go to
Window > Multiplayer > Multiplayer Play Mode
, and check the players you want to spin up. - ParrelSync - From the top menu, go to
ParrelSync > Clones Manager
. If you do not yet have any clones, clickCreate new clone
. Once created, launch the clone instance.
Once installed, you can now set the Auto Start Delay
field on the SteamManager
inspector. If you are automatically starting games to speed up your development process, it is recommended you set this to at least 1,000
to ensure simulated players wait for the main instance to create a lobby to connect to.
Once ready, simply hit play in your main Unity editor instance and host a game. Then, in your simulated player windows or editor instances, start and join the game. For your convenience, SteamManager.Host()
, SteamManager.FindLobby()
, and SteamManager.Connect(ulong)
behave the same on simulated players and connect to the simulated local lobby. Congratulations, you now have simulated networking up and running!
Simulated players will have access to your main instance's real Steam name and icon. Additionally, each simulated player has a distinct icon to allow for easy testing of user interfaces where these may need to be displayed. You can customize these simulated names and icons by setting the Names
and Icons
fields on the SteamManager
inspector.
Simulated Latency
You can simulate ping for both the main editor and simulated clients. Each player can have their own simulated values which can be set on the SteamManager
inspector:
- Ping - The base ping to simulate when sending and receiving local packets.
- Jitter - The ping jitter around the base ping to simulate when sending and receiving local packets.
- Drop Rate - The drop rate percentage to simulate when sending and receiving local packets. For unreliable packets, the packet will be dropped completely with no attempts at resending. For reliable packets, a drop is simulated by doubling the ping, acting as if the first send failed and it had to retry.
- Unreliable Repeats - The maximum number of times the same unreliable packet may be received.
- Unreliable Max Offset - The maximum millisecond delay between consecutive receptions of a repeated unreliable packet.
These values simulate a given client's connection to the Steam relay servers connecting all players in the lobby. For example, if on client A you set the ping to 100
milliseconds and on client B you set the ping to 200
milliseconds, the total time to send between the clients is simulated to be 300
milliseconds. This is because if client A is sending to client B, it takes client A's message 100
milliseconds to reach the simulated Steam relay server, and then another 200
milliseconds for the relay server to send the message to client B.
To save the current latency settings, fill out the Name
field on the SteamManager
inspector and click Save
. This will create or update an existing SteamLatencySettings
ScriptableObject
if one with that name already exists. These are saved to Assets > KaijuSolutions > SteamMultiplayerEngine > Editor > Latency Presets
. You can apply the presets by clicking on their respective name on the SteamManager
inspector, or clicking Apply
on the inspector of a SteamLatencySettings
ScriptableObject
instance. MPE4S comes with some pre-defined settings which you can update or remove as you wish.
- Perfect
- Ping - 0
- Jitter - 0
- Drop - 0%
- Unreliable Repeats - 0
- Excellent
- Ping - 50
- Jitter - 5
- Drop - 5%
- Unreliable Repeats - 5
- Unreliable Max Offset - 2
- Good
- Ping - 100
- Jitter - 20
- Drop - 10%
- Unreliable Repeats - 10
- Unreliable Max Offset - 5
- Poor
- Ping - 250
- Jitter - 50
- Drop - 20%
- Unreliable Repeats - 15
- Unreliable Max Offset - 10
- Bad
- Ping - 500
- Jitter - 100
- Drop - 30%
- Unreliable Repeats - 20
- Unreliable Max Offset - 15
- Terrible
- Ping - 1000
- Jitter - 200
- Drop - 40%
- Unreliable Repeats - 30
- Unreliable Max Offset - 20
Limitations
Certain features are not supported by the simulated players.
- Hosting and Matchmaking - Simulated players cannot host lobbies or browse for lobbies. Thus,
SteamManager.Host()
,SteamManager.FindLobby()
, andSteamManager.Connect(ulong)
behave the same on simulated players and connect to the simulated local lobby. - Host Migration - As the simulated players cannot host lobbies, they cannot simulate host migration. Thus, if the real Steam player leaves the lobby, all simulated players will as well.
- Voice Chat - Simulated players cannot send or receive voice audio. However, they can send and receive text chats.
- Rich Presence - Simulated players cannot get or set any rich presence.
- Multiple Steam Players - Hosting a game while simulating multiple clients and then having another real Steam player connect from another computer is not supported. Depending on what networking integration you use, such as if you are using a client-server model where clients only communicate with the host of the lobby, you may be able to sync some non-Steam data like player object positions, but IDs, names, and icons will not sync between the simulated players and other real Steam players.
- Friends - Simulated players do not have any friend functionality. They will always be detected as friends, both with each other and with the real Steam player.
- Lobby Settings - Simulated players can always join your lobby, regardless of player limits or joining settings. Additionally, they cannot be kicked or banned.
- Exporting - Simulated players only work in the Unity editor and their related code is stripped from exported builds.
If you need to test some of these features, such as matchmaking with multiple real Steam accounts, see the exporting documentation.
Developer UI
A simple developer user interface is provided with MPE4S to allow you to easily test out functionality in builds without needing to create custom user interfaces to do so. Simply add a SteamDeveloperUI
component into the scene. The SteamDeveloperUI
is created using IMGUI so it has no additional dependencies.
- Host, find, or browse lobbies including configuring search settings.
- Manage lobby data and member data.
- Invite friends, kick or ban users, or transfer ownership.
- Handle text chat and voice chat.
- Get and set all rich presence.
- Display log messages.
- Handles all functionality for simulated players.
In the editor, also check out the custom editor windows to help test functionality.