Microsoft Mesh Tutorial: How to Built Interactive Minigames

Caroline LessingerTutorial

Hello, I’m Andrea Hanuja, and in this series, we’re diving into our passion for Mesh and the fascinating world we’ve created with it. In this „Behind the Scenes of MeshMas“ series, we take a look at the technical background of our MeshMas experiences. We start with simple mini-games and progress to the most advanced gamification elements. 

Mini-Games: Simple Interactions with a Big Impact 

In this part, we focus on how to incorporate simple yet fun elements into the environment through physical interactions. These games are intuitive and require no further explanation for the user. They are not only easy to create but also provide an incentive to explore the environment. An important aspect of most physics-based mini-games is the ability to reset their state via a restart button. This is crucial because users need a way to correct unwanted game states. 

A Practical Example: The Jenga Game 

I demonstrate this using the Jenga game as an example. First, I present my configuration, which you are welcome to pause and copy. For a deeper dive into the components, I refer to my „Hello Mesh“ video, where I explain simple interactions using a chess game as an example. Our games are all based on Mesh physics and use Unity Rigidbodies and Colliders, as well as basic mesh interactions. 

Creating an Interactive Button 

The process begins with selecting our button object and adding several components. We need the Script Machine and the Variable component for visual scripting. Then we add the „Mesh Interactable Setup“ component, staying with the default configuration. To make the button visually interactive, we also add an animator, which we will configure later. 

For the Script Machine, we have two settings: embedded and group. This configuration describes where the visual script is saved. Embedded is used for very small, single-use scripts, while group saves the script in an external file, which is typically better for project organization. 

Building the Logic with Visual Scripting 

In the Script editor, we place and connect nodes to build up our logic. We start with a „Mesh Interactable Body is Selected“ node, which exposes a Boolean value indicating if the body is selected. We connect this to an „On State Change“ node, provided by Mesh, which triggers program flow when the input value changes. 

By wiring the value to an „If“ condition, we ensure our logic triggers only if the object was actually selected. Grouping nodes enhances readability, especially for larger scripts. We also create a variable to hold a reference to the parent object of our Jenga game, essential for resetting the game. 

Implementing and Testing the Reset Function 

We try to access a „Reset Body Transforms“ component on the parent object, which saves and resets the initial transform properties of our game. Once everything is connected, we test it in play mode. After ensuring our Jenga game parent object is correctly linked and has the reset component, we see our script works perfectly, allowing us to reset and play a new round of Jenga. 

Enhancing User Feedback with Animations 

Finally, we add an animation to our button for better feedback. We create an animator and an animation clip, which controls the playback of our animation. The animation clip stores the desired movement, and we can use the Animator window to manage it. 

After recording a simple animation and adjusting it for immediate feedback, we integrate this into our visual script, setting up triggers and transitions in the animator. Testing this, we find that the reset works flawlessly, along with the animation. 

Looking Forward 

That wraps up the first video of the series. Stay tuned for the next part, where we delve into more complex gamification elements. See you soon! 

Interested in more tutorials? Check here.