Exploring the Unity MARS Starter Templates
Starter Templates are predesigned, customizable building blocks created to help AR developers save time in Unity MARS to deliver projects faster. Read on to learn more about each of the templates we’ve created. You can follow these instructions to access the Starter Templates in your Unity MARS project.
In conversations with early adopters, we’ve noticed an exciting change as they’ve become familiar with Unity MARS for developing augmented reality (AR) experiences. They’ve stopped talking about how to solve a problem for a specific device, and have begun discussing real-world data and how content connects and adapts to it. The conversation has moved from low-level problems to more advanced scenarios enabled by spatial computing.
Unity MARS introduces a new design language for describing and referencing the real world in a digital context, broadly or specifically, in Editor and runtime. It allows developers to describe and tackle much bigger applications than would be possible otherwise. But like all languages, it must be learned.
Starter Templates are our way of supercharging common workflows used with AR and showcasing the best of what we’ve learned from our customers. Unity MARS currently includes seven Starter Templates:
- Tabletop, 1:1 scale
- Tabletop, 10:1 scale
- Face mask
- Game, basic
- Game, advanced
Here, we take a closer look at them.
For the go-getters and highfliers, you have the option to begin a project with a blank canvas. It includes a preconfigured MARS Session, user, and camera, along with point cloud and plane visualizers to get visual cues when scanning the environment. When you open a Scene in Unity MARS, the first proxy is in place.
Unity MARS creates proxies, or stand-ins for real-world objects, by matching it against positions it finds in the real-world environment. Unity MARS typically adds the user first as the first match for a position, as the user’s position corresponds to the simulation camera.
We wanted users to have an example of the canonical “object showing up on a table” scene. There are quite a few ways to create this kind of setup, such as using Unity MARS’ drag-and-drop workflow or the proxy shortcuts in the Unity MARS panel. The template has the advantage of having all of the condition values already tuned. The object placed is a simple Unity cube. We expect users to replace this cube with their own digital content.
We offer one template at 1:1 scale for interacting with life-sized objects in AR, and another at 10:1 scale. The “miniature” template demonstrates the best practices for creating tabletop visualizations of “large” content, like cities. We generally recommend users create their content at 1:1 scale and then use the “World Scale” parameter of the Unity MARS session to render it much smaller relative to the real world. Content performs best when it is created at life-size and then scaled down – trying to produce small objects tends to lead to precision issues.
Face mask template
The face mask template was designed as a starting point for developers looking to create content that is anchored to a user’s face. You can decorate the model like you would a mannequin. This content can be solid meshes, like funny glasses, or more ethereal things, like particle systems or other visual effect targets. This template includes a face landmark visualizer by default, allowing users to see where Unity MARS understands each tracked face feature to be.
The classic platformer is never far from mind when talking about 3D games. In our game template, we translate this popular game experience – a character maneuvering around an environment to collect objects – into AR.
The template demonstrates how to create a more engaging gameplay experience, where the game has an understanding of each players’ unique physical surroundings. It’s our take on a classic platformer in AR where, rather than exploring a virtual world, we use the real world as our rich environment.
In the game, a robot journeys to collect spinning crystals. The crystals are placed automatically and interact with the real world seamlessly. While this template can serve as the basis for a platformer, we expect users to replace the robot and crystals with their own characters and objects as they bring their game to life. You can see a live demo of this use case.
We offer two variants of our game template, basic and advanced.
Basic template versus advanced template
The basic template was developed using Unity MARS’ drag-and-drop workflow. The content is placed directly on the expected AR planes, resulting in the most straightforward Scene.
The advanced template was created using the same principles and methods used for AR applications with complex game mechanics. Content is authored with semantic tags and forces. Semantic tags allow the Scene to be decorated with “spawn point” locations that all proxies – including the character and the collectibles – match against. Use of forces guarantee the content will not overlap, even if noisy device data results in two extremely close planes overlapping. The resulting Unity Scene is more technically complex (users unfamiliar with Unity MARS concepts may wish to refer to the documentation).
We developed a direct touch control, so the robot will move (or jump, if the path is broken) to the location in the world the user touches on the device. The major advantage this provides is that the robot will always move where the user expects it to. Recentering the character within the user’s view is an intrinsic part of the controls – invaluable given how easy it is to lose track of objects within immersive applications.
The crystals spin and are collected when the robot collides with it. Both the crystal and the robot work independent of Unity MARS – they can be placed in a purely digital environment.
The game templates take advantage of the Unity MARS “replicator” primitive object types. When more than one match for data is available, replicators duplicate the proxy or proxy groups. Both templates use this to match all appropriately sized planes for collision proxies. The basic template has a similar replicator setup for creating entire planes decorated with crystals. The advanced template, instead of placing crystals directly, writes spawn point locations into the world. The spawn point proxy is then replicated and matched against. This actually reduces the amount of content-tweaking needed in the Scene view and supports matching against multiple types of objects simultaneously.
Our goal with the training template is to allow developers to make guided experiences. Guided experiences walk end-users through a series of steps that automatically progress based on customizable triggers. We imagined this for a training use case, to show a user how to perform certain functions.
Developers extend the template by duplicating the prefabs we’ve included in the Scene and modifying them. The experience should be responsive, so that it works optimally whether the user is experiencing it on mobile or head-mounted display (HMD) without requiring different Scenes or builds. Basic interaction is built in.
The training template was designed to work onsite with real equipment. This means it needs to be easy to hook into external systems. We also want to relocalize against a known location or piece of equipment. To do that, we use non-planar proxies.
The training template is made of three pieces: the walkthrough system, the menu (or user interface panel, discussed below), and the responsive Unity MARS actions.
The walkthrough system is a series of steps. Only one step can be active at any time. Each step in turn activates visuals and other scripts.
A step can have any number of triggers that will allow it to progress. We provide a small collection of the most commonly used steps. These include proximity, proxy state, and gaze. Triggers are one-function scripts that tell a step when it can go ahead. Combine this with Unity MARS, and now you can have a step-by-step experience that reacts to the real world.
For the training template, we developed a collection of user interface (UI) components. The main component is a UI panel that indicates the user’s progress. The panel shows every step of the walkthrough along with a description, serving to guide the user through the steps of the training process. The user can access a drop-down list from the navigation bar to skip between steps, as well as view which steps have been completed.
In addition to the main panel, developers can use additional spatial UI components to help users navigate the space and direct their attention to various points of interest. This includes arrows and offscreen indicators that use Unity MARS forces to react to the user’s movement. The arrow prefab uses a force alignment that rotates to always face towards the user, while the offscreen indicator blends between two force alignments based on the point of interests’ screen space position in the field of view (FOV). If the point of interest is out of view, the offscreen indicator’s position is driven by the head pose. But if it isn’t, the indicator moves towards the object to grab the attention of the user.
AR works with many form factors, and we want our training template to work with all of them. The two main device types for experiencing AR are smartphones and HMDs. We categorize these as “flat” and “spatial” immersion levels, respectively.
Responsiveness requires canvas manipulation – the ability to reparent or reposition a UI canvas. On flat devices these elements get locked to the screen; on immersion devices they can exist in space. To be able to manipulate the canvas, we built Unity MARS conditions and actions for each immersion level and then simulated each scenario in the Editor.
There are a few key differences between the flat and spatial UI versions. The position of the “previous” and “next” buttons, as well as the navigation bar, varies according to whether the user is interacting with a screen or a head-mounted display. In addition, the UI panel of steps, while floating in 3D in the spatial version, takes over the entire screen in the flat version. These adjustments fundamentally are based on the affordances specific to each medium.
Stay tuned for new templates
This is an exciting time to be developing with Unity MARS. There is no limit to the use cases to pioneer. These seven Starter Templates are available for you to use now, and we plan to release new templates regularly. We hope you will share your learnings – and your own “templates” – in the forums.
Source: Unity Technologies Blog