For the complete documentation index, see llms.txt. This page is also available as Markdown.

Trigger Logic

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 5

Trigger Logic with Messages

🟡 MEDIUM

In this activity, you will learn how to set up behaviors and components to create simple logic systems with objects as you explore the basics of communications in Game Maker using messages to create cause and effect.

Launch Game Maker

  • Open or create an Experience and move to an area with empty space.

  • Let's turn the grid off and focus on logic.

Collisions & Messages

Behaviours and components are needed to make objects active and/or interactive. This logic provides a framework so messages can be sent and received to trigger gameplay events.

Tags and Broadcast Type allow for greater control over how events are triggered.

Add the following objects to the viewport:

Asset: Door (any) No behavior

Asset: Door (any) Door behaviour

Pressing E next to an object sends the message Interact to it.

Test (Press TAB)

  • Press E to interact with each door. One door is only a prop. The other animates to appear open and turns off its collisions so players can pass through.

Most objects must have collisions to prevent players from passing through them. You can control if an object has collisions, is visible, or has gravity in the Properties Panel.


Toggle Behaviours On/Off

A message sent to an object's Toggle component can turn it's behaviour on or off. Think of it as locking or unlocking a behaviour.

Add an object that sends a message:

Asset: Museum Info Panel

Button component

  • Message to Send: Door.Unlocked

  • Broadcast Type: EveryoneInRange

Create a custom message by typing it into the message field and click to Add it.

Add two objects in range (the yellow sphere) of the first object to receive the message:

Asset: Door (any)

Door behavior

  • Message to Open: Door.Unlocked

Select the existing message from the message dropdown list.

Asset: Door (any)

Door behavior

  • Message to Open: Interact

Toggle component

  • Turn On Message: Door.Unlocked

  • Initial Behaviour State: False (behavior inactive at game start)

Test (Press TAB)

  • Neither door can be opened. Interact with the panel to send its message, and then:

    • One door opens

    • The other door's behaviour is toggled on so players can open the door with E.

Trigger & Filter Messages

Add the following objects to the viewport:

TRIGGER: AVATAR DETECTED Message sent to everything in the Experience (location doesn't matter)

Asset: Door (any) Name: DoorA

Door behaviour

  • Message to Open: DoorA.Open

Asset: Ancient Lever

Message Broadcaster behaviour

  • Message to Send: DoorA.Open

  • Broadcast Type: All

  • Wait Before Broadcast: True

  • Message Required: Interact

TRIGGER: OBJECT COLLECTED Message sent to specific objects

Asset: Door (any) Name: DoorB

Door behavior

  • Message to Open: DoorB.Open

Asset: Key (any)

Collectable component

  • Message On Collect: DoorB.Open

  • Broadcast Type: SelectedActors

  • Broadcast Targets: DoorB

Alternative Method: Add a tag to the door, set the key to broadcast the message to SpecificTagsInRange, and adjust the key's broadcast range to include the door's location.

TRIGGER: TAG DETECTED Message sent to self (when the object detects a specific tag in range)

Asset: Door (any) Name: DoorC

Door behavior

  • Message to Open: DoorC.Open

Speaker component

  • Detection Type: SpecificTagsinRange

  • Include Tags: DoorC.Key

  • Message to Send: DoorC.Open

  • Broadcast Type: Self

Asset: Key (any) Tag: DoorC.Key

Pickable component

Test (Press TAB)

  • Trigger doors A, B, and C to open based on the logic set up. Imagine ways to use these simple trigger methods for other design needs!

There are many more ways to send messages. We'll explore more later.

One Message to Trigger Multiple Objects

Build hidden logic into your Experience with invisible and collision-free Logic Assets.

Add the following objects to the viewport:

TRIGGER: AVATAR DETECTED INSIDE A VOLUME

Asset: Logic Asset

Trigger Volume component

  • Detection Type: EveryAvatarInRange

  • Detection Shape: Box

  • Detection Area: x15 y5 z15

  • Enter Message: Night

  • Exit Message: Day

  • Broadcast Type: All

Asset: Car (any)

Basic Platform behaviour

  • Move Offset: x0 y0 z5

  • Look at Destination: True

Toggle component

  • Turn On Message: Night

  • Initial Behaviour State: False (behavior inactive at game start)

Asset: Weather Asset Name: Night

  • Message Required: Night

  • Profile: Night

Asset: Luxury Street Light

(prop with no logic)

Asset: Logic Light Asset Name: Street Light Position: Luxury Street Light (point down)

  • Light Type: Spot Light

  • Starting State: Off

  • Spot Angle: 15

  • Message Turn ON: Night

  • Message Turn OFF: Day

(2x) Asset: Logic Light Asset Name: Headlight Position: Car headlights (point forward)

  • Light Type: Spot Light

  • Starting State: Off

  • Spot Angle: 15

  • Message Turn ON: Night

  • Message Turn OFF: Day

Test (Press TAB)

  • The lights do not move with the car. Let's create a relationship in the hierarchy to fix that.

Modify

Set the "Headlight" assets to move with the car's platform motion. Open the hierarchy, select them, and drag them onto the Car. This makes them child objects and the car the parent object.

Test (Press TAB)

  • The location of the "Headlight" assets is now controlled by their parent object's motion.

Messages with Arguments

Some special messages appear in yellow and allow you to send information (an argument) with a message.

You can also create custom messages with arguments that will appear yellow in the message dropdown list. These will be explored in a later activity.

Continue with the previous example so weather and the streetlight will gradually change.

Add objects to communicate special messages:

Asset: Logic Asset Name: Street Light Trigger

Message Broadcaster behaviour

  • Message to Send: LightColor

  • Time: 10

  • Wait Before Broadcast: True

  • Message Required: Night

Asset: Logic Asset Name: Weather Trigger

Message Broadcaster behaviour

  • Message to Send: WeatherFade

  • Time: 10

  • Wait Before Broadcast: True

  • Message Required: Night

Modify existing objects to receive the special messages:

Asset: Logic Light Asset Name: Street Light

  • Message Turn ON: Night

  • Message Turn ON: LightColor

Asset: Weather Asset Name: Night

  • Message Required: Night

  • Message Required: WeatherFade

Test (Press TAB)

  • The weather and streetlight gradually change using these special messages.

Follow Up

This activity introduced new tools and concepts to understand objects more and how to make them communicate in custom ways.

In the next activity, you will learn to integrate quests with some of the logic from this activity so you can begin designing a flow for players with clear guidance to play through your Experience.

Ready for More Practice?

This activity leaves room for you to test out your own ideas when the player exits the Trigger Volume and the message Day is sent. Test out custom weather profiles and light colours, too!

Remember that the special message LightColor sets transition timing and colour.


Relevant Resources

Triggering logic is a deep, complex topic. The resources below are beginner friendly so you won't feel overwhelmed. We'll add more to later Begin Game Maker resource sections when topics are covered.


Forum: Community Ideas & Support


Other "Begin Game Maker" Videos

Last updated

Was this helpful?