### Introduction to Desktop Editor Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md Provides an overview of the Desktop Editor for Meta Horizon Worlds, guiding users on how to get started with the creation tools. ```APIDOC Desktop Editor: Introduction: Overview of the Desktop Editor's features and capabilities. Getting Started: Initial steps and setup for using the editor. ``` -------------------------------- ### Custom Model Import: Getting Started Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md Guides users through the initial steps of importing custom 3D models into Meta Horizon Worlds, covering requirements and basic procedures. ```APIDOC Custom Model Import: Getting Started: Initial setup and requirements for importing custom 3D models. Supported Formats: List of 3D model file formats supported (e.g., FBX, OBJ). Import Process: Step-by-step guide for uploading and integrating models. ``` -------------------------------- ### Getting Started with Meta Quest Link Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Build-your-first-game.md Steps to open your tutorial world in the Meta Quest Link desktop application and start building. ```English 1. Open the **Meta Quest Link** application on your desktop. 2. In the Library tab, locate the **Meta Horizon** application. 3. From the context menu, select **Start in Desktop Mode**. 4. In the **Creation Home** page, click **My worlds**. 5. Select your copy of the tutorial template. ``` -------------------------------- ### NPC Assets Guide Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/README.md A guide on getting started with NPC assets. ```markdown ### NPC Assets - [Getting-started-with-NPC-assets.md](Getting-started-with-NPC-assets.md) ``` -------------------------------- ### Creating a Custom Model for Horizon Worlds Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md A comprehensive guide on the process of creating a 3D model from scratch, optimized for use within Meta Horizon Worlds. ```APIDOC Custom Model Creation: Modeling Best Practices: Techniques for creating efficient and performant 3D models. Polygon Count Limits: Guidelines on polygon budgets for different types of assets. Export Settings: Recommended export settings for various 3D modeling software to ensure compatibility. ``` -------------------------------- ### Exploring Tutorial Worlds in TypeScript Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Station-0---Setup.md Guidance on how to explore and modify TypeScript code within Meta Horizons tutorial worlds using a desktop editor. It covers creating copies, starting with simple examples, and reviewing code comments for additional information. ```TypeScript // To explore the TypeScript of this Examples Tutorial, you should use the desktop editor. // You can preview results on your desktop and modify the scripts as needed. // Station 1 represents the simplest example (font display), with each subsequent station adding more complexity or new customUI features. // Comments in the code provide additional information on how to use it. ``` -------------------------------- ### Using TypeScript in Meta Horizon Worlds Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md Explains how to leverage TypeScript for scripting and adding dynamic behavior to Meta Horizon Worlds. Covers basic setup and integration. ```TypeScript // Example of setting up a basic script in Horizon Worlds using TypeScript // Import necessary modules (hypothetical) import { Scene, GameObject, Script } from '@horizon/core'; class MyAwesomeScript implements Script { private gameObject: GameObject; constructor(gameObject: GameObject) { this.gameObject = gameObject; } // Called when the script is initialized onStart(): void { console.log('MyAwesomeScript started!'); // Access properties or components of the GameObject // this.gameObject.getComponent(SomeComponent).doSomething(); } // Called every frame onUpdate(deltaTime: number): void { // Update logic here // this.gameObject.transform.rotate(0, 10 * deltaTime, 0); } } // Register the script with the game engine (hypothetical) // Scene.registerScript(MyAwesomeScript); ``` -------------------------------- ### Setting Up Worlds for Web and Mobile Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md Explains the necessary steps and considerations for configuring Meta Horizon Worlds to be compatible with web and mobile platforms. ```APIDOC Web and Mobile Compatibility: Configuration: Steps to enable and optimize worlds for cross-platform access. Performance Optimization: Tips for ensuring smooth performance on diverse devices. Input Handling: Considerations for adapting controls and interactions for web/mobile users. ``` -------------------------------- ### Learning Path for Complete Beginners Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/README.md A structured learning path for individuals new to Meta Horizon Worlds development. It starts with getting started guides, progresses to creating a first world, and covers the desktop editor and object manipulation. ```Markdown 1. Start with [Get-started.md](Get-started.md) 2. Follow the [Create-your-first-world-tutorial-Overview.md](Create-your-first-world-tutorial-Overview.md) series 3. Learn the [Introduction-to-the-desktop-editor.md](Introduction-to-the-desktop-editor.md) 4. Explore [Adding-and-manipulating-objects-tutorial.md](Adding-and-manipulating-objects-tutorial.md) ``` -------------------------------- ### 3D Modeling Tool Resources Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md Lists recommended 3D modeling software and resources that are compatible with the requirements for creating assets for Meta Horizon Worlds. ```APIDOC 3D Modeling Tools: Recommended Software: List of popular 3D modeling applications (e.g., Blender, Maya). Plugin Information: Details on any necessary plugins or exporters for specific tools. Online Resources: Links to tutorials and communities for 3D modeling. ``` -------------------------------- ### Publishing Worlds on Web and Mobile Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md Details the process of publishing Meta Horizon Worlds that have been optimized for web and mobile accessibility. ```APIDOC Publishing Worlds: Publishing Workflow: Step-by-step guide for submitting worlds to the platform. Platform Requirements: Specific guidelines for web and mobile publishing. Testing and Review: Information on testing procedures and the review process. ``` -------------------------------- ### Asset Templates in Desktop Editor Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md Details the available asset templates within the Desktop Editor, helping creators to quickly integrate pre-made assets into their worlds. ```APIDOC Desktop Editor Asset Templates: Description: Information on utilizing pre-built assets for faster world creation. Usage: Guidance on selecting and applying asset templates. ``` -------------------------------- ### Material Guidance for Custom Models Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md Provides essential information on materials and texturing for custom 3D models to ensure they appear correctly within Meta Horizon Worlds. ```APIDOC Custom Model Materials: Material Setup: Guidelines for creating and configuring materials for imported models. Texture Mapping: Best practices for UV unwrapping and texture application. Shader Compatibility: Information on shaders supported within Horizon Worlds. ``` -------------------------------- ### TypeScript Components, Properties, and Variables Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md Details how to define and use components, properties, and variables within the Meta Horizon Worlds TypeScript environment for robust scripting. ```TypeScript // Example of defining a component with properties and variables in Horizon Worlds TypeScript import { Component, Property, GameObject } from '@horizon/core'; interface MyCustomComponentProperties { speed: Property; message: Property; } class MyCustomComponent extends Component { private internalCounter: number = 0; constructor(gameObject: GameObject, properties: MyCustomComponentProperties) { super(gameObject, properties); } onStart(): void { console.log(`Component started with message: ${this.properties.message.get()}`); } onUpdate(deltaTime: number): void { this.internalCounter += deltaTime; // Update a property value this.properties.speed.set(this.properties.speed.get() + 0.1); if (this.internalCounter > 5) { console.log(`Current speed: ${this.properties.speed.get()}`); this.internalCounter = 0; } } } // Example of how a property might be defined and used in the editor /* GameObject.create({ name: "MovableObject", components: [ { type: MyCustomComponent, properties: { speed: Property.create(10.0, { min: 0, max: 100 }), message: Property.create("Hello Horizon!") } } ] }); */ ``` -------------------------------- ### Tutorial Modules Overview Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup (3).md Provides an overview of the tutorial modules, detailing the sequence and purpose of each module. It highlights the learning objectives, such as building a HUD system, managing puzzles, camera perspectives, player entry/exit, and utilizing interaction APIs like Focused Interaction. ```APIDOC Module 2 - HUD System: Description: Build a HUD system, which allows you to display hints to players to assist in resolving the puzzles. Module 3 - Puzzle Manager: Description: Puzzle Manager displays hints for how to complete individual puzzles. When the puzzle is complete, the Puzzle Manager moves objects to open the pathway to the next puzzle. Module 4 - Camera Manager: Description: Set up the Camera Manager, which manages camera perspectives (first-person or third-person) and field of view for mobile and desktop users. Toggle camera collisions, as needed. Module 5 - Player Manager: Description: Set up the Player Manager, which handles player entry and exit. Player Manager also assigns Camera Manager to each player upon entry. Module 6 - Room A: The Magic Wand: Description: Collect the wand and fire a projectile. Learn how to use grabbables and to fire projectiles. Module 7 - Room B: Secret Code: Description: Learn to use the Focused Interaction API to manage grabbing and rotating objects across multiple devices. Module 8 - Room C: Target Practice: Description: Build bifurcated game mechanics based on device type for VR versus web & mobile users. Module 9 - Summary: Description: Review what you learned and explore ways to expand on the tutorial. ``` -------------------------------- ### Next Steps: Part 2 of Tutorial Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Create-your-first-world-tutorial.md Information on continuing the introductory tutorial by learning to import custom models and write scripts. ```Documentation Continue to Part 2 of the tutorial to learn how to import custom models and write your first script. ``` -------------------------------- ### Asset Deployment Workflow Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup (8).md Steps to deploy an asset from an existing world into your own, including unlinking, creating a new asset template, and resolving script references. ```APIDOC Asset Deployment: 1. Locate Asset Instance: - Find the asset in the Hierarchy panel of the source world (e.g., Chop ‘N Pop: Graveyard Bash). - Note any nodes with attached scripts. 2. Unlink Instance: - Right-click the topmost node of the asset. - Select "Unlink instance root & children" if available. - Note: Some assets may not be instance-based. 3. Create New Asset Template: - Right-click the topmost node again. - Select "Create Asset". - Name and choose a save location for the new asset template. - Click "Save". 4. Deploy to Your World: - Open your File Backed Scripts (FBS) world in the desktop editor. - Navigate to the Asset Library tab. - Locate and drag your newly created asset template into the world. 5. Resolve Script References: - For assets with attached scripts, select each node. - In the Properties panel, identify broken script references (indicated by a broken link icon or similar). - From the "Attached Script" dropdown, select a replacement script from your own world (a copied version of the source script). - At the top of the Properties panel, click "Review" for pending overrides. - In the Template Overrides window, click "Apply All Overrides". - Enter a description for the change. - Click "Save & publish" to finalize the overrides. ``` -------------------------------- ### Scripted Avatar NPCs Development Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/README.md Guides on getting started with, creating, editing appearance, building navigation for, and handling grabbing for Scripted Avatar NPCs. ```markdown ### Scripted Avatar NPCs - [Getting-Started-with-Scripted-Avatar-NPCs.md](Getting-Started-with-Scripted-Avatar-NPCs.md) - [Create-Scripted-Avatar-NPC.md](Create-Scripted-Avatar-NPC.md) - [API-Overview-for-Scripted-Avatar-NPCs.md](API-Overview-for-Scripted-Avatar-NPCs.md) - [Edit-Scripted-Avatar-NPC-Appearance.md](Edit-Scripted-Avatar-NPC-Appearance.md) - [Build-Navigation-for-Scripted-Avatar-NPCs.md](Build-Navigation-for-Scripted-Avatar-NPCs.md) - [Grabbing-for-Scripted-Avatar-NPCs.md](Grabbing-for-Scripted-Avatar-NPCs.md) ``` -------------------------------- ### TypeScript Version Note Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup (1).md This note informs users that all tutorials are created using TypeScript 2.0.0 and provides a link to learn more about upgrading their own world to this version. ```TypeScript // Note: All tutorials are created using TypeScript 2.0.0. // Learn more about upgrading your own world to TypeScript 2.0.0. // See: https://developers.meta.com/horizon-worlds/learn/documentation/tutorial-worlds/getting-started-with-tutorials/tutorial-prerequisites/ ``` -------------------------------- ### Scripting NPC Gizmo Behavior Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/NPC-gizmo (1).md Information on customizing NPC gizmo behavior through scripting. It directs users to API overviews and getting started guides for scripted avatar NPCs. ```text To customize the behavior of your NPC gizmo through scripting, see [API overview of scripted avatar NPCs](/horizon-worlds/learn/documentation/desktop-editor/npcs/scripted-avatar-npcs/api-overview-for-scripted-avatar-npcs). See also [Getting started with scripted avatar NPCs](/horizon-worlds/learn/documentation/desktop-editor/npcs/scripted-avatar-npcs/getting-started-with-scripted-avatar-npcs). ``` -------------------------------- ### Basic NavMesh Setup and Pathfinding Example Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Navigation-mesh-generation.md Demonstrates how to set up the NavMeshManager, get a NavMesh reference by name, and perform a pathfinding query using the NavMesh API. This includes importing necessary modules and defining a component to manage the process. ```typescript import NavMeshManager, {NavMesh} from 'horizon/navmesh'; import * as hz from 'horizon/core'; type Props = {}; class ExampleNavAgentScript extends hz.Component { static propsDefinition: hz.PropsDefinition = {}; navMesh!: NavMesh; public start = async () => { // The manager/`directory` is responsible for procuring navmesh references. // The `getInstance` result can be cached, or the method can be called again later as needed. const directory = NavMeshManager.getInstance(this.world); // The directory allows us to get references to any navmesh profile we've defined in the editor. const mesh = await directory.getByName('NPC'); if (!mesh) { console.log('No navmesh available! Did you type the name wrong?'); return; } // The reference can be treated as a first-class object and stored, passed around, etc. this.navMesh = mesh; // Finally, we can do something with the navmesh reference. this.findPathExample(); }; private findPathExample = () => { // Get a path from the origin to (5,0,5) const path = this.navMesh.getPath( new hz.Vec3(0, 0, 0), new hz.Vec3(5, 0, 5), ); if (path) { // access `path.waypoints` } }; } hz.Component.register(ExampleNavAgentScript); ``` -------------------------------- ### start Method Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/CodeBlocks-to-TypeScript.md An empty 'start' method within the 'ExampleScript' class. This method is used for component initialization logic that runs when the world starts, similar to the 'when world is started' event. ```typescript start() { } ``` -------------------------------- ### Meta Horizon Worlds Desktop Editor Controls Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup (2).md Explains how to navigate and interact within the Meta Horizon Worlds desktop editor. Covers movement controls in Preview mode and the use of simulation playback controls for testing TypeScript scripts. ```apidoc Build mode and Preview mode: When you open your world, it is in **Build mode**; to explore the world and playtest it, click the **Preview mode** button. For more information on the various modes, click [here](/horizon-worlds/learn/documentation/desktop-editor/getting-started/user-interface/operational-modes) . In Preview mode: * Use the mouse and WASD controls to move in the world. * In Preview mode, you move at a single speed. * To jump, press SPACEBAR. It’s a good idea to test any required jumping distances in Preview mode. * To leave Preview mode and return to Build mode, press ESC. Note that exploring the world in Preview mode is not the same thing as playing the game experience. In the toolbar, next to the mode controls, you can see the simulation playback controls. **Tip**: You can also explore the world in VR mode from the desktop and through the VR headset itself. When you are testing your TypeScript, you must press the **Play** button to start the simulation, which activates and executes your TypeScript scripts. You can also use the **Stop** button and **Reset** button for your playtesting. ``` -------------------------------- ### Get Player Variable (Number Example) Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Persistent-Variables.md Example of retrieving a number-type persistent variable for a player using `getPlayerVariable`. ```TypeScript // names of the variable group and persistent variable containing player data const varGroupName: string = "varPlayerGlobals"; const varName: string = "player_score"; // Set as a Number const varKey: string = `${varGroupName}:${varName}`; this.connectCodeBlockEvent(this.entity, CodeBlockEvents.OnPlayerEnterWorld, (player: Player) => { const playerScore = this.world.persistentStorage.getPlayerVariable( player,varKey ) as number; console.log("Player score: " + playerScore); }); ``` -------------------------------- ### Weapon Types and Projectile Management Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup (1).md This table outlines the different weapon types available in the tutorial, detailing their projectile management methods and a brief description. It highlights the use of Projectile Launcher gizmo for basic guns and Raycast gizmo for laser guns. ```APIDOC Weapon Types: Basic Gun: Projectile Management: Projectile Launcher gizmo Description: Launches a physical object (projectile) outward into the world. This object can be tracked for collision purposes. Laser Gun: Projectile Management: Raycast gizmo Description: Fires an invisible ray out into the world. Its physical representation is a visual effect. ``` -------------------------------- ### Adding Debug Print to start Method Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/CodeBlocks-to-TypeScript.md Demonstrates how to add a console log statement within the 'start' method to verify script execution in Meta Horizon Worlds. ```typescript start() { console.log('hello world'); } ``` -------------------------------- ### Get Player Variable (Object Example) Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Persistent-Variables.md Example of retrieving and handling an object-type persistent variable for a player using `getPlayerVariable`. Includes type checking and default value handling. ```TypeScript // names of the variable group and persistent variable containing player data const varGroupName: string = "varPlayerGlobals"; const varName: string = "player_details"; // Set as a JSON Object const varKey: string = `${varGroupName}:${varName}`; this.connectCodeBlockEvent(this.entity, CodeBlockEvents.OnPlayerEnterWorld, (player: Player) => { const valueJson = this.world.persistentStorage.getPlayerVariable( player,varKey ); let playerStats: {[key: string]: any}; if (valueJson === 0) { // Default value from store playerStats = { player_name: player.name.get(), player_rank: "Beginner", }; } else { // Saved data retrieved, cast to an object playerStats = valueJson as object; }; console.log(playerStats.player_rank); }); ``` -------------------------------- ### Meta Horizon Worlds Game Systems Overview Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup (8).md This section outlines the key game systems that form the foundation of the Chop N Pop: Graveyard Bash tutorial world. These systems are designed to be modular and reusable for creators. ```APIDOC Game Manager: Manages the overall game state, including starting and ending waves, and game progression. Floating Text Manager: Handles the display of floating text elements within the world, such as scores or notifications. Player Manager: Manages player-related functionalities, including player spawning, health, and interactions. Loot System: Controls the spawning, collection, and effects of in-world items like ammo clips, weapons, and health potions. Weapons System: Manages the functionality of different weapons, including aiming, firing, reloading, and ammo management. Enemy Wave Manager: Controls the spawning and behavior of enemy waves, including enemy types, wave composition, and timing. NPC System: Manages non-player characters (NPCs) within the world, potentially including enemy AI and behavior. ``` -------------------------------- ### Blender Beginner Tutorials Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/3D-Modeling-Tool-Resources.md Links to beginner-friendly tutorial series for Blender, covering navigation, modeling, texturing, lighting, and rendering. These resources are suitable for new users. ```en Blender Guru’s Beginner Tutorial Series: https://www.blenderguru.com/tutorials/blender-beginner-tutorial-series Blender Fundamentals on YouTube: https://www.youtube.com/playlist?list=PLa1F2ddGya_-UvuAqHAksYnB0qL9yWDO6 CG Cookie’s Beginner Courses on YouTube: https://www.youtube.com/@cg_cookie Grant Abbitt’s Blender Tutorials on YouTube: https://www.youtube.com/c/GrantAbbitt ``` -------------------------------- ### SimpleObjectGrab Component Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/CodeBlocks-to-TypeScript.md Handles grabbing and resetting of an object to its original position and rotation. It connects to grab start and end events, clearing any pending reset on grab start and initiating a reset timer on grab end. ```typescript import * as hz from class SimpleObjectGrab extends hz.Component { static propsDefinition = { } preStart(){ //#region Built-in Event Handlers this.connectCodeBlockEvent( this.entity, hz.CodeBlockEvents.OnGrabStart, this.OnGrabStart.bind(this) ) this.connectCodeBlockEvent( this.entity, hz.CodeBlockEvents.OnGrabEnd, this.OnGrabEnd.bind(this) ) //#endregion Built-in Event Handlers } start() { //Set the original position and rotation of the object. this.originalPosition = this.entity.position.get() this.originalRotation = this.entity.rotation.get() } //#region Private Variables private resetTimer: number = 0 private originalPosition: hz.Vec3 = new hz.Vec3(0, 0, 0) private originalRotation: hz.Quaternion = new hz.Quaternion(0, 0, 0, 0 //#endregion Private Variables OnGrabStart(r: boolean, p: hz.Player ) { //cancel the reset timer if the object is grabbed. this.async.clearTimeout(this.resetTimer) } OnGrabEnd(p: hz.Player) { //reset the object to its original position and rotation after 5 seconds. this.resetTimer = this.async.setTimeout(() => { this.entity.position.set(this.originalPosition) this.entity.rotation.set(this.originalRotation) }, 5000) } } hz.Component.register(SimpleObjectGrab) ``` -------------------------------- ### Meta Horizon TypeScript V2 Changes Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Where-to-start-with-Meta-Horizon-Worlds.md Documents the changes and updates introduced in Version 2 of the Meta Horizon TypeScript API, crucial for migrating existing projects or starting new ones. ```TypeScript // Documentation for Meta Horizon TypeScript V2 Changes /* Version 2 introduces several key changes to the TypeScript API for Meta Horizon Worlds: 1. **Module System Update**: The core module imports have been refactored. For example, `import { Scene } from '@horizon/core';` might now be `import { SceneManager } from '@horizon/scene';`. 2. **API Signature Changes**: Certain methods may have updated parameter lists or return types. For instance, a `GameObject.findByName` method might now require an optional namespace parameter. * **Before V2**: `GameObject.findByName("MyObject")` * **After V2**: `GameObject.find("MyObject", { namespace: "default" })` 3. **New Features**: Introduction of new APIs for enhanced functionality, such as advanced physics interactions or new event handling mechanisms. * Example: `Physics.addForceField(config)` 4. **Deprecations**: Some older methods or properties may be marked as deprecated and scheduled for removal in future versions. It is recommended to migrate away from these. * Deprecated: `GameObject.getComponentByType(Type)` * Recommended: `GameObject.getComponent(Type)` **Migration Guide**: Refer to the official migration guide for detailed steps on updating your existing TypeScript projects to V2. */ ``` -------------------------------- ### PlayerCamera Overview Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup.md Overview of how the player avatar’s camera works in Meta Horizon Worlds, including PlayerCamera objects and code. ```APIDOC PlayerCamera: - Represents the player's camera in Meta Horizon Worlds. - Manages camera behavior and properties. PlayerCameraManager: - Manages PlayerCamera objects. - Provides an interface for interacting with the player's camera. ``` -------------------------------- ### Conditional Playback Example Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/World-publishing-guide.md Demonstrates how to play an animation on start using a timeout for conditional execution. ```javascript const animatedEntity = ... // Get your AnimatedEntity // To play conditionally on start, use a small timeout: animatedEntity.preStart = function() { setTimeout(() => { animatedEntity.play(); }, 100); }; ``` -------------------------------- ### Initializing a Git Repository Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Version-Control-Video-Tutorial-with-PigeonNo12.md This snippet demonstrates the basic command to initialize a new Git repository in a project directory. This is the first step in using Git for version control. ```bash git init ``` -------------------------------- ### Get TextGizmo reference Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Create-your-first-world-tutorial,-part-2.md Retrieves a reference to the Text gizmo from the component's props and casts it to the `hz.TextGizmo` type in the `start()` function. ```javascript // Store a reference to scoreView as its specific type: TextGizmo. let scoreGizmo = this.props.scoreView?.as(hz.TextGizmo); ``` -------------------------------- ### Preview Mode Controls Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup (1).md Describes the keyboard controls for navigating and interacting within the Preview mode of the Meta Horizons editor. This includes movement, jumping, and exiting Preview mode. ```APIDOC Preview Mode Controls: Movement: Mouse and WASD keys Jump: SPACEBAR Exit Preview Mode: ESC key ``` -------------------------------- ### Local Script Behavior on Entity Ownership Transfer Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Getting-Started-with-Local-Scripting.md Details the behavior of local scripts when an entity's ownership transfers. This includes the invocation of the `start()` method, the resetting of entity properties and script variables, and specific event handling considerations. ```apidoc Entity Ownership Transfer Behavior: 1. **`start()` Method Call:** The `start()` method of the local script is invoked when the entity ownership changes. * Events fired before or during the transfer are lost. * Scripts can be reset upon ownership change. 2. **Entity Properties and Script Variables:** * All entity properties and script variables revert to their default values upon ownership transfer. * To maintain state (e.g., usage counts, personalization), persist information separately and update values using events during ownership transfer. 3. **Event Handling Considerations: * `OnPlayerExitWorld`: Local scripts do not receive this event if the owning player leaves. Use 'Default Execution' mode for tracking and notification. * `OnPlayerEnterWorld` and `OnPlayerExitWorld`: Local scripts do not receive these events when toggling between preview and build mode in World Builder. Use 'Default Execution' mode for tracking and notification. * `OnGrabEnd` and `OnAttachEnd`: These events are not sent to local entities if the owner exits the world while holding the entity. Create a default script to track these events and notify the entity. Local scripts for the player run on the server when the player exits the world. ``` -------------------------------- ### Accessing and Copying Tutorial Worlds Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Access-Tutorial-Worlds.md This section details the process of creating a copy of a tutorial world. It outlines the steps required when using the desktop editor, including navigating the Meta Quest Link application, selecting the development environment, and choosing the tutorial world. It also describes the in-headset method, involving the Create menu and Tutorials tab. ```APIDOC Desktop Editor: 1. Open Meta Quest Link application. 2. Navigate to 'Library' > 'Apps'. 3. Select the development environment. 4. In Creation Home, click 'Tutorials'. 5. Select the desired tutorial world. 6. A copy of the world is created with you as the owner. In Headset: 1. Go to the Create menu in your headset. 2. Click the 'Tutorials' tab. 3. Select the world of interest and click 'Start'. ``` -------------------------------- ### preStart Method Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/CodeBlocks-to-TypeScript.md An empty 'preStart' method within the 'ExampleScript' class. This method is intended for component initialization logic that should run before the 'start' method. ```typescript preStart() { } ``` -------------------------------- ### Get Player Entitlement Quantity Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/World-Inventory-API-Guide.md Retrieves the quantity of a specific in-world item that a player possesses. Returns 0 or a positive integer. ```javascript /* * Returns the player in-world item quantity for the SKU. */ this.connectCodeBlockEvent(this.entity, hz.CodeBlockEvents.OnPlayerEnterWorld, (player) => { WorldInventory.getPlayerEntitlementQuantity(player, "item_sku").then((itemQuantity) => { // 0 or a positive integer of how many they have console.log("Player has quantity: " + itemQuantity); }) }); ``` -------------------------------- ### Custom UI API - Setup and Basic Components Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Custom-UI-API-Introduction.md This snippet outlines the initial steps for using the Custom UI API, including setting up the desktop editor and adding the CUI API to your worlds. It also covers creating base UIComponent scripts and displaying text on the CUI. ```en Setup The Desktop Editor Add the CUI API to your worlds Create Base UIComponent Scripts Display Text On CUI ``` -------------------------------- ### Teleport Player to Location Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Example-scripts-library.md Teleports the local player to a specific location (10, 5, 0) when the component starts. ```typescript import { Component, Player, Vec3 } from "horizon/core"; class TeleportPlayer extends Component { start() { // Get the local player const player = this.world.getLocalPlayer(); // Define the teleport location const teleportLocation = new Vec3(10, 5, 0); // Teleport the player player.position.set(teleportLocation); } } Component.register(TeleportPlayer); ``` -------------------------------- ### Custom UI Performance Tips Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Station-0---Setup.md Provides recommendations for improving the performance of custom user interfaces in Meta Horizons. Key advice includes avoiding certain event handlers, optimizing update loops, and managing UI element visibility. ```General * Avoid using or updating custom UIs in conjunction with the world.onUpdate event. * Avoid making updates to the display of the panel using for/next loops. * Each time that a panel is updated requires a network call. * Split multiple custom UIs across multiple Custom UI gizmos. * Try to make custom UIs as flat as possible. * Every layer in a visible custom UI is rendered, even if it is not seen. * Set panels that are not being shown to users to be invisible, which stops them from being rendered. ``` -------------------------------- ### Managing Audio Playback with TypeScript Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Meta-Horizon-Worlds-Audio-Ingestion.md When 'Play on Start' is disabled for an Audio gizmo, its playback must be managed programmatically using TypeScript. ```TypeScript // Example of managing audio playback via TypeScript // Assuming 'audioGizmo' is a reference to an Audio gizmo component // To play the audio: audioGizmo.play(); // To stop the audio: audioGizmo.stop(); // To check if audio is playing: let isPlaying = audioGizmo.isPlaying; // To set volume (0.0 to 1.0): audioGizmo.volume = 0.8; // To set pitch (-24 to 24): audioGizmo.pitch = 5; // To enable looping: audioGizmo.loop = true; // To disable looping: audioGizmo.loop = false; ``` -------------------------------- ### Custom UI API - Examples and Advanced Features Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Custom-UI-API-Introduction.md Demonstrates practical applications of the Custom UI API, including implementing background images, creating instruction boards, and setting up scrollable views. It also points to further documentation for advanced learning. ```en Background Image Example Instructions Board Example ScrollView Example Learn more in docs Tutorials -Custom UI ``` -------------------------------- ### TypeScript Version Requirement Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup (3).md All tutorials are created using TypeScript 2.0.0. This section informs users about the specific TypeScript version required for the tutorial and provides a link to upgrade their own worlds. ```TypeScript // Note: All tutorials are created using TypeScript 2.0.0. You can learn more about how to upgrade your own world to TypeScript 2.0.0. See [Getting Started with Tutorials](/horizon-worlds/learn/documentation/typescript/upgrade-world-to-typescript-api-v200). ``` -------------------------------- ### Get World Purchasables by SKUs Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/World-Inventory-API-Guide.md Fetches details for purchasable items in the world based on a provided list of SKUs. It returns an array of 'InWorldPurchaseable' objects. ```javascript /* * Returns a list of any in-world purchase items with SKUs that match the given list of item SKUs. */ this.connectCodeBlockEvent(this.entity, hz.CodeBlockEvents.OnPlayerEnterWorld, (player) => { const skus = [“item_1_sku”, 'item_2_sku”']; WorldInventory.getWorldPurchasablesBySKUs(skus).then((purchaseableItems) => { console.log("Number of items: " + purchaseableItems.length); purchaseableItems.forEach((item) => { console.log("Item name: " + item.name); console.log("Item SKU: " + item.sku); console.log("Item description: " + item.description); console.log("Item price: " + item.price.priceInCredits); console.log("Item quantity: " + item.quantity); console.log("Item isPack: " + item.isPack); }); }) } ``` -------------------------------- ### TypeScript API v2.0.0 Documentation Reference Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup.md This entry provides a link to the official API documentation for TypeScript version 2.0.0 used in Meta Horizons development. It serves as a reference for all available scripting functionalities. ```APIDOC API v2.0.0 documentation: https://horizon.meta.com/resources/scripting-api/index.md/?api_version=2.0.0 ``` -------------------------------- ### Unity Developer Familiarity in Meta Horizons Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/Module-1---Setup (8).md Explains how Meta Horizons code may reflect familiar Unity development practices. Specifically, it mentions the `preStart()` method potentially calling the `Awake()` method on a class, providing a bridge for Unity developers. ```Unity C# // Example of Unity-familiar structure: public class ExampleSystem { public void preStart() { // This might call Awake() on another class, similar to Unity's lifecycle. Awake(); } private void Awake() { // Unity-like initialization logic } } ``` -------------------------------- ### Get All Player Entitlements Source: https://github.com/sean-thompson/meta-horizons-documentation/blob/master/MetaDevelopersLearn/World-Inventory-API-Guide.md Retrieves all entitlements a player currently holds. This function uses async/await for asynchronous operations and returns an array of entitlement objects. ```javascript /* * Example showing how to get all player entitlements using async/await */ this.connectCodeBlockEvent(this.entity, hz.CodeBlockEvents.OnPlayerEnterWorld, async (player) => { // Returns an array of all entitlements the player has const entitlements = await hz.WorldInventory.getPlayerEntitlements(player); entitlements.forEach((entitlement) => { console.log("Entitlement SKU: " + entitlement.sku); }); }); ```