This activity is included in an 8-part, 1 hour series to learn Game Maker. Short, focused topics with guided practice will give you practical experience building useful logic for creating games.
Begin Game Maker 8
Design Multiplayer Game Logic
π΄ COMPLEX
In this activity, you will learn the fundamentals of setting up logic layers for multiplayer games, which combines logic individual players experience and synchronized logic all player experience. This includes how variables in the Rules System and Spawn Point behaviors can be used to create teams. Finally, you will learn how to share your Experience for testing or publish it to The Sandbox Map if you own LAND.
How Does Multiplayer Work?
Two Logic Layers
Multiplayer Experiences synchronize data across all players, such as object motion.
However, not all logic needs to be Synchronized [MP] for all players. To improve gameplay performance, some logic can be managed on the individual, or Client [SP], layer.
When adding logic to an object, you can see a dropdown filter for these communication layers.
Launch Game Maker
Open the Experience from the previous activity to reuse some of its logic.
Object Logic
Some behaviours/components only have a [MP] type to prevent conflicts with collisions, movement, etc.
Consistent Type
To be compatible in multiplayer games, an object may have only [SP], only [MP], or no logic.
Remove all logic from an object to change between [SP] and [MP].
Practice: Try to add a [SP] Toggle component to the logic asset with [MP] Weather Switcher behaviour added in an earlier activity. You can only add the [MP] version of Toggle.
Consistent Communications
In singleplayer Experiences, [SP] and [MP] logic can communicate because all data is managed locally.
In multiplayer games, [SP] and [MP] logic only "interacts" with its own layer (send/receive messages, detect, collide, spawn, replace, have a parent/child relationship, etc).
Gameplay Recommendations
In Game Maker 0.10, the Objectives system only communicates with [SP] logic. This limitation will be removed in 0.11, allowing compatibility with [MP] logic.
Practice: Use the recommendations below to build one or two logic examples in your practice experience based on the gameplay you're interested in exploring.
To make a multiplayer Experience feel seamless for players and perform better, use as much [SP] logic in place of [MP] logic as possible.
Gameplay
When to use SP
When to use MP
Speaker component
When information is only relevant for an individual player
"Barks" to hint all players to talk to an NPC, share general information, etc.
Dialogue (Asker behaviour)
When each player triggers dialogue at their own pace
Compatibility with quests (0.10)
When all players must see dialogue at the same time
Collectables
(includes
consumables & equipment)
When each player can collect an item (and you need to use less MP logic for improved performance)
SP compatibility is needed
When players compete to collect only one instance of an object (Global set to True)
OR
When every player can collect an instance of the object (Global set to False)
MP compatibility is needed
Any use of Game Rules (HUD, banner, key input, variables, etc)
No limitations
(Set Broadcast Type to All to communicate with Game Rules)
No limitations
(Set Broadcast Type to Rules or All to communicate with Game Rules)
Quests
Only SP logic can communicate with quests in Game Maker 0.10
The Quest system will be compatible with MP logic in Game Maker 0.11
Logic that controls movement, collisions, spawning/ destroying, etc.
No SP options exist to avoid physics conflicts
Minimize use to boost gameplay performance
Refer to performance recommendations in Game Maker to choose how many and which logic to use to create an outcome
Use Actor Property Switcher instead of destroying and respawning objects
Variables
The Game Rules system can communicate with [SP] or [MP] logic.
In Game Maker 0.10, global variables apply to all players and local variables apply to individual players. Both work in single player games.
Example: You can create a global currency for all players to share or local currency for each player to use on their own.
Practice: You already have a global variable to count ancient treasures collected from a previous activity. Create a local player variable (integer) named "Player Treasure" with initial value 0. Place collectable Ancient Treasure B that sends the message TreasureB.Collect to Rules. Add a Math rule to add a fixed value of 100 to the new variable.
Game Maker 0.11 will rename the local variable type to "player" and introduce a new "team" variable.
Teams
Messaging
Game Maker 0.10 introduced a new way to send messages only to certain teams of players.
Teams are defined by placing multipleSpawn Points that assign teams randomly when players arrive in the game.
Once teams are defined, you can set the Broadcast Type on most logic to Team and select the teams you created from a dropdown list.
Practice: Select the Avatars Portal asset and set "Assign Team" to true. Create a team name. Duplicate this object, move it nearby, and create a new team name for it.
Customizations
Once teams are created via Spawn Point behavior, you can do the following within that logic:
Choose equipment the team will wear (which can be unique to the team and set them apart)
Add custom tags for various types of detection
Add some available components via Avatar's Feature to set the team apart (e.g., light, sound, etc.)
Practice: Open each Spawn Point you created and set different equipment per team. At the bottom of the behavior, click "Add Feature" under the Avatar's Feature section. Apply Visual FX and choose a different trailing visual effect for each team.
Team Variable
A Team variable in Game Maker 0.11 will make it possible to track scores, times, etc. by teams assigned in the Spawn Point.
Resetting & Instances
Instances are different play sessions of an Experience. A new instance opens when a maximum number of players join one. An instance closes after a period of inactivity.
Some games must be reset to replay before an instance closes. Logic triggers need to be included in your design to set things back to their original state for players (e.g., variables, respawning removed objects, etc).
This requires careful planning before building your game logic for a single playthrough, and how to do it will vary depending on the gameplay you're designing. Keep this in mind early on as you design logic to create a Experience you want to publish to LAND or share in the Gallery.
Experiences must be marked as multiplayer to allow multiple players to enter.
Test Your Multiplayer Experience
Game Maker is great for rapid testing of singleplayer games, but will not allow multiple players to enter for testing a multiplayer game.
You can either generate a test link to open it in the Game Client or share to the public Gallery for testing and feedback.
MULTIPLAYER EXPERIENCE TESTING
Share to the Gallery
Shared Experiences are public and can be removed from the gallery when needed. They can be entered into Game Jams and used for playtesting with friends. You can also create a free Experience Page to tell players about a shared experience, but keep in mind they can not be linked to from the page or monetized.
Practice: Share your practice Experience to the Gallery (don't forget to mark it as multiplayer) and test the logic you created with a friend. Remove it from the Gallery when you're done.
Publish to the Map
You must own LAND (NFT) to publish your Experience to The Sandbox map and monetize. See our documentation to Publish Experiences.
Our Experience Manager can help you draw in players from the map, create a free Experience Page linked to your Experience, and track player analytics.
Practice: Visit The Sandbox Map to find featured UGC (User Generated Content) Experiences published by our community of creators. Explore their Experience Pages and games to see how you can publish your own.
Follow Up
Multiplayer is a deep and complex topic because it opens up many more game types and specialized approaches to create gameplay. We've introduced some of the key considerations so you can begin to explore it further.
We encourage you to start building your first multiplayer Experience once you feel confident with how to use Game Maker's systems to build logic for a singleplayer Experience.
Resources
Learn how experts at The Sandbox create a game from concept to launch with our Game Production Guide. It provides actionable steps to build a high quality singleplayer or multiplayer Experience with helpful supportive resources.
Visit The Sandbox Creators Forum
Join the community at our forum to find updates, ask questions, support other creators, and more!
Practice: Try to send a message to trigger the [MP] Weather Switcher with a [SP] Message Broadcaster. In singleplayer mode it will work, but in multiplayer mode it will not.
For the most accurate multiplayer results, generate a link to test it in the Game Client software using the button in Game Maker (top right).