LogoLogo
DocumentationWebsiteCommunityPortal
  • Get Started
    • Quickstart
    • Tutorials
    • Wizards
  • Features
    • Release Notes
      • 2024
        • 04-05 Apr Update
        • 03-27 Mar Update
        • 02-07 Feb Update
        • 01-23 Jan Update
        • 01-05 Jan Update
      • 2023
        • 12-18 Dec Update
        • 11-30 Nov Update
        • 10-30 Oct Update
        • 10-04 Oct Update
        • 09-18 Sep Update
        • 09-11 Sep Update
        • 08-28 Aug Update
        • 08-14 Aug Update
        • 07-23 July Update
        • 07-14 July Update
        • 06-16 June Update
        • 06-6 June Update
        • 05-16 May Update
        • 03-31 Mar Update
        • 03-16 Mar Update
        • 03-10 Mar Update
        • 02-07 Feb Update
        • 01-24 Jan Update
        • 01-10 Jan Update
      • 2022
        • 12-08 Dec Update
        • 11-13 Nov Update
        • 11-07 Nov Update
        • 10-26 Oct Update
        • 10-14 Oct Update
        • 10-01 Oct Update
        • 08-26 Aug Update
        • 08-02 Aug Update
        • 07-01 July Update
        • 06-08 June Update
        • 05-20 May Update
        • 05-05 May Update
        • 04-25 Apr Update
        • 02-11 Feb Update
        • 01-28 Jan Update
        • 01-10 Jan Update
      • 2021
        • 12-10 Dec Update
        • 12-01 Dec Update
        • 11-26 Nov Update
        • 11-17 Nov Update
        • 11-12 Nov Update
        • 11-09 Nov Update
        • 11-02 Nov Update
        • 10-26 Oct Update
        • 10-21 Oct Update
        • 10-14 Oct Update
        • 09-27 Sep Update
        • 08-31 Aug Update
        • 07-20 July Update
        • 07-02 July Update
        • 06-31 June Update
  • Metaverse
    • Building
      • Portal
        • Team Members
        • Defining Global Variables
      • Editor
        • File Manager
          • Selecting a file
          • Sketchfab Integration
        • Placement in 3D Space
        • Project Settings
          • Preferences
          • Branding
          • Collaborators
          • Menu
          • Variables in Settings
          • Lead Generation
          • Tour Mode
          • Advanced
          • E-Commerce in Settings
        • Preview
          • Headset Testing - WebXR Emulator
        • Viewport Properties
        • Editor Keyboard Shortcuts
      • Scenes
        • 3D Scene
          • Avatar System
          • Colliders
          • Zones
          • Lights
        • 360 Scene
        • Orbit Scene
      • Elements
        • Image
        • Video
        • Audio
        • GIF
        • Text to Speech
        • Character
        • Character AI
        • Actionbar
        • Timer
        • Polygon
        • Linked Popups
        • Variants
      • Rules
        • Shared Rules
        • How Rules Work
        • Number Variable Rules
        • String Variable Rules
        • Boolean Variable Rules
      • Variables
        • Autogenerated Variables
        • String Substitution
        • Capturing User Input
      • Build FAQs
    • Publishing
      • URL or QR Code
      • Embed on your Website
      • Full-Page HTML
      • Embedding within Apps
        • Android Embed
        • React Native Embed
      • Export as SCORM package
      • Authentication
        • SSO
        • Password With Expiry
        • Email with OTP
        • Custom List
        • Token
        • Load from another Experience
      • Publishing FAQs
      • Private Cloud Deployment
    • Multiplayer
      • Host Mode
      • Broadcast Mode
      • Voice Chat
      • Text Chat
      • Video Chat
      • Screenshare
      • Comments
      • Share Reactions
      • Notifications
      • Troubleshooting webcam and microphone
    • Analytics
      • Advanced Analytics
      • Leaderboard
      • Viewer Sessions
    • Integrations
      • GMetri with SCORM
        • Embed a SCORM package in a GMetri experience
      • Live Stream on GMetri
        • Live Stream Zoom on YouTube
        • Live Stream Zoom on Vimeo
          • Zoom Setup
      • E-Commerce with GMetri
        • Shopify Integration
        • WooCommerce Integration
        • Custom Integration
        • Using an E-Commerce Plugin
      • Adding a Chatbot
      • Sending data to GMetri Deployment
    • Viewing
      • Avatars
      • First/Third Person
      • Concurrency
      • Oculus Controls
      • Viewer Keyboard Shortcuts
      • IT Permissions
        • Whitelisting for Viewing Experiences
        • Whitelisting for Editing Experiences
        • Whitelisting for Analytics
        • Subprocessors
    • GMetri SDK
      • GMetri Player
      • GMetri SDK APIs
        • Project
        • Deployment
        • File
        • Viewer Group
      • GMetri Webhooks
      • API Token
      • Examples
  • Guidelines/Compatibility
    • Guidelines
      • Content Creation Guidelines
        • XR Experience Storyboard
        • 360 Degree Video Shoots
        • Avatars vs Characters
        • Designing 3D Models for Immersive VR mode
      • Asset Guidelines
        • 3D Models
          • Export GLB/GLTF from 3DS Max
          • Export GLB/GLTF from Blender
        • 360 Pano Images Render
        • Resources for Assets
        • Asset FAQs
        • Image Aspect Ratio
      • Experience Optimizations
        • Scene Optimizations
          • Performance Monitor
        • Image Optimizations
        • Audio Optimizations
        • Video Optimizations
        • 3D Model Optimizations
      • Workflows
        • Green Screen
          • Apply Green Screen to Videos
          • Accurate Color Selection
        • QR Code Scanner
        • Adding Sprites
        • Adding Background Music & Persistent Logo
        • EmbedHTML Snippets
    • Compatibility
      • Platform Requirements - Viewer
      • Platform Compatibility Matrix
      • Supported File Formats
      • Supported Browsers
      • Capture Network and Console Logs from Chrome Browser
    • Limitations
      • iOS Limitations
      • VR Mode Limitations
  • Platform
    • Billing
    • Platform FAQs
    • Security
    • Legal
Powered by GitBook
On this page
  • Order Matters
  • The Mental Model for Rules
  • Implications of the Rules Mental Model
  • When do Rules Run?
  • Common Rule Triggers
  • Recreated per Scene
  • Initialization of a Scene
  • Checking if a Variable is Equal to Another

Was this helpful?

Edit on GitHub
Export as PDF
  1. Metaverse
  2. Building
  3. Rules

How Rules Work

It may help, when building complex experiences, to note the following properties about Rules in GMetri.

Order Matters

  • Rules are executed in order of definition. So on the rules page if you have these rules in the following order, then Video1 would end up in a paused state, as that executes last:

    • First Rule: "When Video1 is clicked, Then Video1 should play"

    • Second Rule: "When Video1 is clicked, Then Video1 should pause"

  • Within a single rule, the "When Events" are checked in order

  • Within a single rule, the "Then Actions" are executed in order. So if you have a rule like the following, the image would end up hidden.

    • "When something is clicked, Then Image1 should show AND Image1 should hide"

The Mental Model for Rules

It is helpful to think of the "When" side of rules as a series of pipes, that are either green or red in color. If any of the When events get triggered, the system decides if its a hit or a miss, and paints the pipe either red (No go) or green (Good to go).

The reason the paint analogy works, is because the when event states persist.

"is clicked" is a special rule that paints the pipe green for exactly one Rules check, and then paints it red again.

"has been clicked", in contrast to "is clicked", paints the pipe green, forever. However, these events do trigger and check if the rule should be executed everytime.

Example:

Let's say we have the following rule, based on a "count" integer variable:

When (count is = 2 AND Image1 is clicked) Then (you_have_passed_text should appear)

  • Let's say count becomes 1. Then the "count is = 2" when event is checked - it's obviously not true, so the system paints "count is = 2" pipe red. Whenever the image is clicked, its counter part is red, so this rule wont trigger.

  • When count becomes 2, the first pipe is painted green, and clicking on Image1 will trigger the rule.

  • Again, once count become 3, the first pipe is painted back red.

Implications of the Rules Mental Model

This mental model also makes clear a few important points:

  • If a pipe is already green, painting it green again will have no impact.

    • Example, for the rule "When a > 2, then ...", when a goes above 2 and becomes 3, this rule gets triggered once. But after that, a becoming 4, 5, 6 etc will have no impact (as the pipe is already green).

  • Variable When Events trigger when they change: "When variable_a changes" when event is triggered ONLY if the value stored in variable_a changes. Lets say its value is "hello", and we set it to "hello" once again, this rule isn't triggered again. Because truly, the variable_a did not change.

  • Click based When Events trigger every time.

  • If you have a rule that says "When Image1 is clicked AND Image2 is clicked", it would very likely never trigger. This is because "is clicked" makes the pipe green for excely one Rules check and then paints it red again. For this rule to trigger, the user would have to click both the images at the same instant. What you more likely want in a scenario like this is "When Image1 has been clicked AND Image2 has been clicked"

When do Rules Run?

  • Rules require a trigger to run. Any of the "When Events" can provide the trigger. A trigger needs either a single green pipe (in case of OR) or all green pipes (in case of AND) to flow through successfully and fire the rule.

  • In case of "AND" linked when events, all "pipes" (When Events") need to be green for the trigger to actually run (fire) the rule.

  • In case of "OR" linked when events, any single pipe being green, and the generation of a trigger (in that pipe) is enough to actually run (fire) the rule.

Common Rule Triggers

  • An "on click" when event always generates a trigger. However for "on click" the pipe becomes red immediately after the trigger. If there's any other pipe (i.e. when event) linked to it using an "AND" condition, and the pipe is red at that instant, the rule won't fire.

  • A "has been clicked" when event also generates a trigger. But there's no negation happening here - once the pipe is green, it stays green, until the scene changes.

  • A "variable_a changes" when event is similar to "has been clicked". Once the variable changes because of any rule, the pipe stays green. You may want to use this event as a trigger generator on every value change of a variable.

  • A "variable_a > 5" (or any other variable comparison) based when event generates a trigger at the instant the condition becomes true. If the condition is already true and the variable changes again in a way that keeps the condition true, no new trigger is generated. Note: A variable pipe that is already green, won't trigger again unless it goes red (i.e. condition becomes false) and then becomes green again (only a color change qualifies as a trigger for variable comparison when events).

Recreated per Scene

Rules are defined per scene at a time.

When a viewer enters a GMetri experience, the Rules are initialized for the scene that the viewer is in. On every scene change, the older engine is dismantled and a new one is created for that scene. So when you go from Scene1 to Scene2 and back to Scene1, all the "is clicked" when events get reset back to the initial state (of not being clicked yet).

Initialization of a Scene

Whenever a viewer enters a new scene, the following things happen, in order:

  • The scene's preload event is fired. You can use this event to show/hide videos or audios that you want to autoplay on scene start. Any rules defined with the when event "When scene preloads" get triggered here.

  • Any elements that are set to "autostart" (like any audios), autostart at this time.

  • All variables based rules are checked with their current values. So if you have any when events like "When variable_a is = 2 then ...", they are triggered at this point.

  • The scene's load event is fired. Any rules defined with the when event "When scene loads" get triggered here.

Checking if a Variable is Equal to Another

You can use variable substitution to check if a variable is equal to another. Example:

When variable_a is = {{variable_b}}

However, this check will be triggered only whenever variable_a changes, and not when variable_b changes. So to check for variable equality, we need to use the following rule:

When variable_a is = {{variable_b}} OR variable_b is = {{variable_a}}

PreviousShared RulesNextNumber Variable Rules

Last updated 1 year ago

Was this helpful?

Checking for variable equality