Module 1 - Intro to Desktop Editor and TypeScript
Important
This content is intended as a companion to the tutorial world of the same name, which you can access through the desktop editor. When you open the tutorial world, a copy is created for you to explore, and this page is opened so that you can follow along. For more information, see Access Tutorial Worlds. In this tutorial, you create a simple platformer-style game where players run and jump through a world as they collect gems.
Key game development areas
This tutorial covers a reusable and flexible co-op game setup, in which all players work together to collect gems. This tutorial walks through the basics of using the Meta Horizon Worlds desktop editor application to build the world and the TypeScript required to power a game that works in VR and on 2D desktop screens.
Game development areas include:
- Keeping track of all players in the world
- Managing game state
- Player and object collision
- Dependency injection and direct reference in scripts
- Events
- Implementing the Observer Pattern using the Meta Horizon Worlds event system
- Displaying dynamic text
- Basics of using the desktop editor
- Basics of building scripts in TypeScript
- Build a basic Game Manager
- Game states
- Initialize game
- Keeping score
- End game and resetting the game
- Events
- Event listeners
- Broadcast events
- Entity (local) events
- Entity collisions
If you haven’t done so already, please review the Getting Started section for tutorials, which includes information on:
- Tutorial prerequisites and assumptions
- How to acquire a copy of this world for yourself
- How to use tutorial worlds and assets in your own worlds
- Developer tools and testing for your worlds
You can follow along the steps of the tutorial content in a copy of the world of your own. After you have copied the world, you can compare the steps of the tutorial to the completed world.
Desktop editor: To create a copy of this tutorial on a tutorial world from the desktop editor, click
Tutorials in Creation Home and then select
Intro to Desktop Editor and TypeScript. For more information, see
Access Tutorial Worlds.
VR headset: To build the world described in this tutorial, make your own copy of the Intro to Desktop Editor & Typescript tutorial world, by selecting it from the Tutorials tab in the Create menu. See below.
Explore the complete world If preferred, you can jump into the completed world and review the script and systems that are covered in the tutorial. The finished TypeScript files from this tutorial are included in the project with filenames that end with: _COMPLETE
.
Grab stuff from this world and use it in your own project! For more information on how to apply assets or scripts from this world to yours, see
Use Assets from Tutorials.
To begin, open your copy of the tutorial world in the desktop editor.
- Open the Meta Quest Link application on your desktop.
- In the Library tab, locate the Meta Horizon application in which to build your version of the world.
- From the context menu for the application, select Start in Desktop Mode.
- In the Creation Home page, click My worlds in the left navigation bar.
- Select your copy of the tutorial template.
- Your world opens in the desktop editor, and it should look something like the following:
Build mode and Preview mode In the above and when you first open the world in the desktop editor, the world is in Build mode, which is indicated by the deselected Play button in the toolbar:
In Build mode, you add, edit, and remove the entities that compose your world.
Preview mode:
To explore the world and playtest it, click the Play button, which opens Preview mode. When you are testing your TypeScript, you must press the Play button to start the simulation, which activates and executes your TypeScript scripts. Press the Stop button to stop the simulation.
By default, when you press the Play button, you enter Preview mode and start the world simulation, which means that all valid scripts in the world are executed. So, you can choose to launch Preview mode as if you were entering it like a player or, if needed, to disable the world simulation so that you can explore it without any scripted activity to interrupt.
In the toolbar, next to the mode controls, you can see the simulation playback controls. The Reset button restarts the simulation as if the world was launched from the beginning.
Note that exploring the world in Preview mode is not the same thing as playing the game experience. It should be used for debugging during development, but you should always test your worlds on all applicable target devices prior to publication.
Preview controls:
Control | Description | Notes |
---|
WASD and mouse
| Movement | In Preview mode, you move at a single speed. |
SPACEBAR
| Jump | It’s a good idea to test any required jumping distances in Preview mode. |
ESC
| Leave | Press ESC once to pause Preview mode, which enables you to interact with the desktop editor UI.
Press ESC to exit Preview mode completely. |
Note: You can also explore the world in VR mode from the desktop and through the VR headset itself.
In the desktop editor, you can see that a course for your game is provided. You are welcome to change the course to anything you like. This tutorial leaves the course layout as it is.
Some tips if you change the course - Get in the habit of building your maps offset from the origin
(0,0,0)
, which makes snapping easier in the editor. - You can drag and drop entities in the Hierarchy panel to reorganize them as you see fit. Reparenting entities groups them together and retains their positioning relative to their parent entity.
- Use Preview mode to move around the world to see if it feels fun. Add more fun by creating jumps and hidden areas.
Let’s get started with the tutorial. You should see a single green gem on the course. Create four duplicates of the green gem asset provided in the template.
- In the Hierarchy panel, search for:
emerald
. - Right-click on the emerald entity in the hierarchy:
a. If the emerald is not in main viewport, select Focus on selection.
b. Select Duplicate.
- The new instance appears at the bottom of the list in the Hierarchy. Select it.
- Repeat the above steps until you have 5 total gems.
These gems all have the exact same position and rotation as the source gems. In fact, you cannot tell in the main panel that there are five gems!
So, you should move them around the course. Select each gem in the Hierarchy panel, and use the Move tool, shown below, to reposition it. Gems should be placed about chest high on an avatar, so that players can easily run into them. You can also edit the Position properties in the right-hand panel for more precise positioning.
Example course:
Make sure to drop into Preview mode to check out your course.
Done with Module 1! In this module, you:
- Verified prerequisites
- Opened the tutorial world in the desktop editor
- Built your layout
- Added gems
- Tested your world
- Switched between Build mode and Preview mode
In the next module, you start building scripts in TypeScript.