Set Up Mechanics
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.
Last updated
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.
Last updated
Copyright ©The Sandbox. All Rights Reserved.
In this activity, you will learn the basics of the Game Rules system and how to apply it for more engaging game mechanics that can be used repeatedly. This visual scripting system is an efficient tool for designing behind the scenes logic using variables, unlocking many new gameplay varieties and a customizable HUD, or heads up display, for the player.
STAY ORGANISED IN GAME MAKER
Group rules into rulesets any way you like.
Group objects in the hierarchy using folders.
Find messages sent and received with the Message Inspector in the Debug menu.
Manage messages used in your Experience in the Settings menu.
The Game Rules system is a visual scripting tool located in the Gameplay menu.
It allows you to set, use, and change values such as numbers, text, time, and true/false values for your gameplay needs and control what appears on the player HUD, or heads up display.
Open the Experience from the previous activity to reuse some of its logic.
The Game Rules System is a powerful visual scripting tool running behind the scenes to manage information and gameplay.
Other rule presets make it easy to track points, add time trials, set poison or hunger for players, and more. It's also possible to build a complex resource management system where messages with arguments trigger amounts of resources to be traded or purchased.
With rules, you can even define what variables are for all players and which ones will be tracked differently for each player. We'll explore that in the next activity about multiplayer games.
Rule: Popup Window Type: Game Screen
Required Message: Playerjoined
Title: Welcome!
Description: Explore as a player to test the logic you create.
Rule: OnPlayerJoin Type: Events
Message to Send: Playerjoined
Variable Type: Text
Apply variable: Global Name: Area Value: Banner Text
Rule: Banner Type: Game screen
Required Message: Night
Duration: Fixed value of 5 (seconds)
Variable: Area
Name: Area
Icon: Map
Logic Asset
Trigger Volume component
Enter Message:
Message (with argument): Area
Argument 1: Text
Argument name: Area Name
Argument value: Area 1
Broadcast type: Rules
Logic Asset
Trigger Volume component
Enter Message:
Message (with argument): Area
Argument value: Area 2
Broadcast type: Rules
Rule: Set Text Value Type: Replace Variable Values
Required Message: Area
Text variable: Area
New text: Message Argument, select argument name you created
[MP] Asset: Numpad Switch Invisible
Projectile behaviour
Start with Experience: True
Message Required: none
Projectile Force: 40
Projectile Trajectory: 0
Look at Direction: True
Collision Target: SpecificTags
Tags to Collide With: artifact
Message on Collision: Health
Health: - 100
Broadcast Type: CollidedActors
[MP] Asset: Dragon Egg
Visual FX Component
Beverage wisp
Pickable component
Offset: x0
y-0.5
z0
Note: This offset adjusts the object location when it is picked up.
[MP] Asset: Numpad Switch
Location: Inside the dragon egg asset Child object of the dragon egg Invisible
Asset Spawner behaviour
Message Required: 1
Use Preset: True
Preset: Select your projectile preset
Only once: False
Rule: Key Input Type: Triggers
Select Key: 1
Message to send onKeyDown: 1
Asset: Ancient Treasure A Tag: treasure
Indicator component
Linked Quest ID: Treasure Hunt
Quest cursors: True
Objective: Treasure Hunter
Collectable component
Collect Sound: Generic Coin
Message on Collect: Treasure.Collect
Broadcast Type: All
Note: Each time this object is collected, the message is sent to all systems.
Modify Assets: Ancient Artifact Tag: artifact
Health component
Health: 10
Drop component
Use Preset: True
Preset: Select your treasure preset
Variable Type: Number
Apply variable: Local Name: Money Value: 0
Rule: Math Type: Math
Required Message: Treasure.Collect
Operand 1: variable, Money
Operator: Add
Operand 2: Fixed value, 100
Result: Money
Note: This amount replaces the variable.
Rule: HUD Type: Game Screen
Required Message: Playerjoined
Select slot: Top center slot
Variable: Money
Name: Treasure
Choose icon and size
Note: This displays the variable on the HUD from when a player enters the game.
Asset: Bazaar Merchant
Asker behaviour
Question: "What would you like to buy today?"
A1: "Food"
A1 message: ShopItem1
A2: "Equipment"
A2 message: ShopItem2
A3: "Wood"
A3 message: ShopItem3
Asset: Any food item
Collectable component
Consumable: true
Note: Press C
in Inventory to use
Message on consume: Speed
, Percentage 20, Duration 10
Note: This gives a 10 second boost
Logic Asset
Asset Spawner behaviour
Message required: ShopItem1Purchased
Asset to spawn: any equipment asset
Component: Collectable
Logic Asset
Asset Spawner behaviour
Message required: ShopItem2Purchased
Spawn preset (toggle): true
Preset: the food preset you created
Variable Type: Number
Apply variable: Local Name: Wood Value: 0
Rule: Math Type: Math Name: +Wood
Required Message: ShopItem3Purchased
Operand 1: Wood variable
Operator: Add
Operand 2: Fixed value, 5
Result: Wood variable
Note: This adds 5 to the wood variable
Rule: HUD Type: Game Screen
Required Message: Playerjoined
HUD slot: any bottom slot
Variable Type: Text
Apply variable: Local Name: Purchase Status Value: You don't have enough money
Rule: Banner Type: Game Screen
Required Message: ShopPurchaseFailed
Duration: Fixed value of 5 (seconds)
Variable: Purchase Status
Name: Purchase Status
A forum post has been created for this learning activity! Visit to:
Ask or answer questions
Post ideas about the topic
Share what you've learned or created
from the activity
from the bonus resources