LogoLogo
GeneralAccountsPlayersOwnersCreatorsThe Sandbox Website
Creators
Creators
  • 🎆Welcome to the Creator Portal
  • 🟦Learn Creator Basics
    • 🟦Scale & LAND Use
    • 🟦Assets & Equipment
    • 🟦Avatars & Character
    • 🟦Look & Feel
    • 🟦Logic & Gameplay
    • ❓FAQs: Gameplay
    • ❓FAQs: Assets
    • 🧙‍♂️Begin Game Maker (Video Series)
  • The Sandbox Creators Forum
  • The Sandbox DAO
  • 🪙Monetisation
  • Game Maker
    • ✨Create Experiences
    • 🔰Beginners
      • Play/Test
      • Build with Blocks
      • Place Assets
      • Set Object Actions
      • Trigger Logic
      • Craft Quests
      • Set Up Mechanics
      • Build Multiplayer Games
    • Game Maker 0.11 Update
    • 0.11 Upgrade Guide
    • 📖Docs
      • Navigate Game Maker Home
      • Manage Experiences
      • Controls & Shortcuts
      • Build Menus
        • Top Bar
          • Gameplay
        • Side Bar
          • Hierarchy
          • Presets
        • Library & Quick Access Bar
        • Grid System & Snap Tool
        • Properties Panel
      • Using Blocks
      • Using Assets & Objects
        • Behaviour & Component Parameters
        • Tags
        • Messages
      • Behaviours
        • NPC - AI Pawns
          • 🔵Citizen
          • 🔵Farmer
          • 🔵Healer
          • 🔵Melee Enemy
          • 🔵Predator
          • 🔵Prey
          • 🔵Soldier
          • 🔴Friendly NPC
        • Movement
          • 🟡Door
          • 🟡Bird
          • 🔴Basic Platform
          • 🔴Advanced Platform
          • 🔴Projectile
          • 🔴Rotate
        • Basic Logic
          • 🔵Message Broadcaster
          • 🟢Combination Code
          • 🟢Asker
          • 🟢Timed Events
          • 🟡Crowd Event
          • 🔴Spawn Point & Avatar's Feature
        • Modifiers
          • 🔵Actor Property Switcher
          • 🔵Multi
          • 🔵Void
          • 🟢Asset Spawner
          • 🟢Replace Asset
        • Visual
          • 🟢Post Process Effects
          • 🟡Weather Switcher
          • 🟡Animated Decoration
      • Components
        • Actions
          • 🟢Climbable
          • 🟢Avatar Teleport
          • 🟢Collectable
          • 🟢Drop
          • 🟢Slide
          • 🟢Speaker
          • 🔴Pickable
        • Triggers
          • 🟢Plant
          • 🟢Switch
          • 🟢Button
          • 🟢Trigger Volume
        • Status
          • 🟢Toggle
          • 🟢Power Up
          • 🔴Avatar Checkpoint
          • 🔴Health
        • Gameplay
          • 🔵Defeat
          • 🔵Victory
          • 🔴Raycast
        • NFT
          • 🟢NFT Sensor
          • 🟢NFT Image Display
          • 🟢Image Display
          • 🔴NFT Details Display
        • Display
          • 🟢Indicator
          • 🟢Rarity VFX
          • 🟡Visual FX
          • 🟡Light
        • Audio
          • 🟡Play Sound
      • Objectives
      • Game Rules
        • Math
        • Time
        • Comparisons
        • Replace Variable Values
        • Game Screen
        • Triggers
        • Events
      • Build Singleplayer & Multiplayer Logic
      • Quality Guidelines
        • Optimisation
        • Testing
        • Playability
      • Templates
    • 📑Creative Guides
      • 📗Game Rules Guide
        • Point Race
        • Collect Points
        • Time Trial
        • Combo
        • Hunger
        • Poison
        • Shop
      • ⚙️Logic Guide
        • Abilities
        • Equipment Based Logic - On Equip / NFT Sensor
        • Doors & Chests
        • Collectibles
        • Text, Quests & Icons
        • Platforms
        • Victory & Defeat
        • Miscellaneous
        • NFT Inspect
        • Fighting
      • 🏞️Experience Guide
        • Tower Defense
        • Horror / Backrooms
        • Solo Platforming
        • Social Platforming
        • Resource Management
        • Cooking Simulator
        • Survival
        • Action / Adventure
        • Night Clubs & Concerts
        • Virtual Home & Architecture
        • NFT Gallery / In-Game Shop
        • Puzzle Games
        • Social Hubs
        • Simulation
      • 🎲Experience Design Techniques
        • Narrative Design
          • Worldbuilding
          • Storyboard
          • Dialogue
        • Art Design
          • Experience Art Concept
          • Asset Curation
          • Blockout Aesthetics
          • Detailing / Dressing
        • 3D Spatial Layout
          • Rough Base Map
          • Greyboxing / Blockout
        • Game Design
          • Ramp of Difficulty
          • Risk & Reward
          • Game Loops & Decisions
    • 🎬Game Production Guide
      • 🟥Concept
      • 🟧Blockout
      • 🟨Logic
      • 🟩Art
      • 🟦Quality Assurance
      • 🟪Polish
      • ⬜Marketing
    • 🧰Publish Experiences
      • Experience Manager
        • Experience Analytics
        • 🧰Experience Page
          • Content Guide
          • Marketing
          • Create an Experience Trailer
          • Player Engagement
        • Map Location
        • Asset Review
        • Access Restrictions
      • Collaborating With Third Parties
      • ❓FAQs: Experience Publishing
    • 🕘Version Notes & Changelogs
      • Game Maker 0.11
        • ❗0.11 Upgrade Guide
      • Game Maker 0.10
      • Game Maker 0.9
      • Game Maker 0.8
      • Game Maker 0.7
    • ❓FAQs: Game Maker
  • VoxEdit
    • ✨Create Assets
    • 🔰Beginners
    • 📖Docs
      • Navigate VoxEdit Home
      • Controls & Shortcuts
      • Panels & Custom Layouts
      • Block
      • Modeler
        • Use Modes & Tools Together
        • Set the Pivot Point
        • Create Frame Assets
      • Animator
        • Build a Rig
        • Create an Animated Asset
        • Use Inverse Kinematics
      • Templates
      • Quality Guidelines
        • Asset Types & Collisions
        • Asset Scale
        • Node Efficiency
        • Pivot Point & Alignment
        • Animation
        • Visual Quality
        • Asset Name & Description
        • Manage Files & Folders
    • 📑Creative Guides
      • 🧍Asset Guide
        • Structures & Landmarks
          • Basic Building: No Entry
          • Animated Building: No Entry
          • Unanimated Building: Player Entry
          • Landmark
          • Building Facade
          • Structure Component Parts
          • Modular Architecture
        • Humanoids & Animals
        • Vehicles
        • Equipment
        • Art: Statues, Paintings
          • Animated Art Screens
          • Statues
          • Kinetic Art Sculptures
          • Paintings
          • Performance Art
        • Furniture
        • Platforms
        • Doors, Gates, and Windows
          • Multi Design Door Asset
        • Chests & Other Animated Interactions
        • Plants, Trees
        • Objects, Machines
        • Signs & Text
        • Obstacles
        • Create Frame Assets
      • 🎨Art Techniques
        • Asset References
        • 3D Design
          • 🧹Need to Simplify?
          • ✂️Trim All Volumes
          • 🟢Optimize with Texture
          • 🟢Curved Edges: Blocky Style
          • 🟡Break Down Objects
          • 🟡Create Smooth Angled Lines
          • 🟡Circular Shapes: Cross Technique
        • Colour, Texture & Depth
          • 🪅Colour Choice & Strategy
          • 🧱Textures & Materials
    • 🧰Upload Assets to Workspaces
    • 🌟Mint & List Assets to Sell
    • 🕘Changelogs
    • 🔓Open Source Assets
    • ❓FAQs: VoxEdit
  • Creators Program
    • 🏗️Builders' Challenge
      • Rules & Eligibility
      • Earnings & Rewards
      • How to Succeed in the Builders' Challenge
      • ❓FAQs: Builders' Challenge
    • ℹ️Creator Contests
    • 🏆Game Jams
      • Rules & Guidelines
      • Judges & Voting
      • Explore Past Winners
      • ❓FAQs: Game Jams
    • 🏆VoxEdit Contests
      • Rules & Guidelines
      • Judges & Voting
      • Explore Past Winners
      • ❓FAQs: Voxel Art Contests
  • General
    • 📚The Sandbox Documentation
    • 🔄Play, Create & Earn
    • 🗺️Map
    • 🛒Marketplace
    • 🗣️Discord Community
    • 🔗Social Networks, News & Blogs
    • The Sandbox Linktree
    • ❓Help & Contact
Powered by GitBook
LogoLogo

INFO

  • Discord
  • Social, News & Blogs
  • Service Status

PLAY

  • Events
  • Map
  • Avatar

CREATE

  • VoxEdit
  • Game Maker
  • Contests

OWN

  • SAND
  • LAND
  • Staking

Copyright ©The Sandbox. All Rights Reserved.

On this page
  • Begin Game Maker 7
  • Add Game Mechanics with Rules
  • Follow Up
  • Relevant Resources
  • Forum: Community Ideas & Support
  • Other "Begin Game Maker" Videos

Was this helpful?

  1. Game Maker
  2. Beginners

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.

PreviousCraft QuestsNextBuild Multiplayer Games

Last updated 5 months ago

Was this helpful?

Begin Game Maker 7

Add Game Mechanics with Rules

COMPLEX

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.

What are Rules?

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.

Launch Game Maker

  • Open the Experience from the previous activity to reuse some of its logic.

A rule needs to be triggered by a Message In to carry out its actions. It can then trigger objects, other rules, etc. Some rules can also be interrupted with a message.

Trigger: Joining the Game

Let's begin with a simple popup window that appears when a player enters the game:

Test

Press TAB to test. The popup window appears as soon as the Experience starts for you.

For now, let's set the Popup Window rule's Required Message to none so the window won't pop up every time we press TAB to enter the game and test logic.

Use a Text Variable in a Rule

Use text variables to show status, player/location names, level up notices, and more!

Create a variable and a rule to use it:

Test

In a previous activity, the message Night is sent anytime the player enters an object's trigger volume. The banner will display the words "Banner Text," which is the value saved in the variable.

Overwrite a Text Variable and Reuse It

Let's create a message with arguments to send different text to the Rules System depending on where the player is located in the game world.

Now create a rule to overwrite the variable's text with the message argument:

Test

The banner rule doesn't use the text argument sent with the message, but still works. The rule to sets banner text uses the argument text included with the message.

Trigger: Keypress (to shoot projectiles)

Create a preset of the following asset. Delete the object after saving it as a preset.

Note: With these settings, the projectile will cause 100 damage if it hits an object that has the tag artifact, which was applied to objects in the previous activity.

Now create a pickable object with a child object that spawns the projectile preset:

Add a Key Input rule to trigger the projectile to spawn whenever a key is pressed:

Test

Press TAB to test. Pressing the 1 key shoots the projectile from the dragon egg anytime. Pick up your magical dragon egg with E and shoot all ancient artifact assets to collect the treasure!

Since an object that is picked up can’t send or receive messages in the current version of Game Maker, we created a child object to be the asset spawner. The projectile behavior triggers as soon as the object it’s applied to is spawned.

The Raycast component can detect objects from a distance and send messages, too!

Count Resources with a Number Variable

Place the treasure preset from the last activity. Modify its collectable component so it will send a message to the Game Rules system whenever it is collected. Save this preset over the old version. Delete the object after saving it as a preset.

Modify all of the Ancient Artifact assets to drop the preset when destroyed:

Duplicate an Ancient Artifact asset until there are at least 20 in the game. Spread them out.

Create the following variable and rules to track and display money:

Test

Press TAB to test. Now as you destroy the ancient artifacts and collect the treasure that drops, you'll see the amount of treasure collected (100 per treasure). Each time you collect the treasure, which is a preset, you’re sending a message to a custom location.

In this case, it goes to All locations so it will reach the Rules system and increase your money when collected, which appears in the HUD slot you selected.

Make Variables Useful

Create an NPC to sell different types of items to players (equipment to wear, a consumable item, and a resource to be shown in the player HUD):

Create a preset object to spawn when purchased (delete after saving as a preset):

Create asset spawners for items to purchase and collect:

Add variables and rules for resources that will be tracked by number and displayed in the HUD:

Add a Shop rule preset to save time on the rest of the setup:

You already set up the Add Money, HUD, and Player Join rules earlier in this activity. You can remove the ones in this premade ruleset.

The remaining rules allow you to test if you have enough money to buy two types of items and pay from your money variable if you do have enough.

You have three items in your shop, so select and duplicate a Success, Fail, and Pay rule in this Ruleset to add what's needed for your third item.

Rename Item 1 rules "Purchase Food Success," "Purchase Food Fail," and "Pay Food." Rename Item 2 rules for equipment and item 3 rules for Wood to make it easier to track what each rule does in your custom setup.

Set the price of each item in the Success and Fail rules so it will check if you have enough and send a message if you don't, and use the same value in the "operand 2" value of the Pay rules to match and subtract an item's cost from your Money. Based on the number of treasures your game has, set food to cost 1, equipment to cost 4, and wood to cost 2, for example.

The messages sent by each rule matches the rest of the logic in the activity, but you can use custom messages to keep track of things more easily.

Finally, add a text variable and rule to inform players when they don't have enough money:

Test

If you destroyed some artifacts and collected treasure, you have money to spend with the merchant. You can set custom costs for each item in the Rules System and spawn any type of item you like or add resources for gameplay using variables.

Try opening your inventory to wear the equipment you purchased or consuming the food item that triggers a speed Power Up. The purpose of the items you buy are completely up to you.

Follow Up

The Game Rules System is a powerful visual scripting tool running behind the scenes to manage information and gameplay.

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.



Forum: Community Ideas & Support


Other "Begin Game Maker" Videos

Play/Test
Build with Blocks
Place Assets
Set Object Actions
Trigger Logic
Craft Quests
Set Up Mechanics
Build Multiplayer Games

The Game Rules system is a visual scripting tool located in the menu.

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 where messages with arguments trigger amounts of resources to be traded or purchased.

Relevant Resources

🔰

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

➕
Gameplay
resource management system
🔴

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

Cover
Game Rules

Unpack all of the details of the Game Rules system to deepen understanding

Cover

Find details on each rule (or right click a rule in Game Maker for this info)

Cover
Game Rules Guide

See logic templates to learn Game Rules and presets documentation

Cover
Resource Management

Explore a whole new world of game variations using the Rules system to track player resources

Cover

Copy and paste this ruleset and integrate with objects to count anything

Cover
Equipment Based Logic - On Equip / NFT Sensor

Use our counting ruleset for various events when the player equips an item

Visit the Forum
📗
Cover
Event Count & Check