text
stringlengths
0
1.11k
yield return new WaitForEndOfFrame();
}
Debug.Log("AlignmentAnchorManager: Finished Alignment!");
OnAfterAlignment.Invoke();
}
This moves the player so that wherever the shared spatial anchor object is, it ensures that the player is relative to that object, the same way that the player in OVR Space is relative to the spatial anchor.
ChatGPT
The Unity SharedSpaces showcase app provides a practical demonstration of integrating the Platform SDK with networking solutions like Photon Realtime and Unity Netcode for GameObjects to enable multiplayer interactions within a Meta Quest app. Here's a detailed breakdown of how to set up and utilize this showcase app:
1. Enable Platform SDK Features
Start by enabling features like Destinations in the Meta Quest Dev Center and complete the Data Use Check Up. This setup is essential for using Meta's Platform APIs efficiently.
2. Set Up Networking
The app uses Photon Realtime for the networking layer. You'll need to create an account with Photon, set up a new application, and obtain an App ID which will be used within your Unity project to manage multiplayer sessions.
3. Integrate Unity Netcode for GameObjects
This handles the replication of GameObjects across different sessions, ensuring that all players have a synchronized view of the game state.
4. Configure the Meta Quest Layer
In this layer, you handle the integration with Meta's Platform APIs. This includes setting up group presence, using destinations for navigation, and managing lobby and match sessions. This layer is crucial for handling the logic related to Meta Quest’s specific features like matchmaking and session management.
5. Set Up Photon Realtime Layer
Configure Photon to handle the transport layer, which involves the transmission of packets between users. In the SharedSpaces app, Photon manages rooms where users join and communicate based on their match or lobby IDs. The primary peer in these rooms acts as the listen-server.
6. Clone and Set Up the SharedSpaces App
Clone the SharedSpaces repository from GitHub, set up the necessary configurations in the Unity project, and integrate the app with your Meta Quest Dev Center and Photon settings.
7. Build and Test
After setting up all components, build the project in Unity and upload the app to a release channel in the Meta Quest Developer Hub. This allows you to distribute the app to registered users for testing.
8. Multiplayer Setup
Test the multiplayer setup by joining different devices into the same Photon room using the match or lobby IDs configured in your app settings. Ensure that all players can interact and that the game state is synchronized across all sessions.
9. Debug and Optimize
Monitor the performance and stability of the app. Use Photon's and Unity’s debugging tools to troubleshoot and optimize the network communication and game logic.
Key Learning Points:
Integration of Platform SDK: Understanding how to integrate and utilize Meta’s Platform SDK for features like group presence and destinations.
Networking: Setting up and managing a robust multiplayer environment using Photon Realtime.
Game Replication: Using Unity Netcode for GameObjects to ensure consistent and synchronized gameplay across different users.
This tutorial provides a comprehensive guide to building a multiplayer VR app that leverages Meta's Platform SDK, Photon Realtime, and Unity Netcode for GameObjects. By following these steps, developers can create engaging and interactive multiplayer experiences for Meta Quest users.
User
Scene Integration In DroneRage
Unity
Quest
The platform for which this article is written (Unity) does not match your preferred platform (Nativa).
Haz clic aquí para ver la página del índice de la documentación para tu plataforma de preferencia.
DroneRage has drone ships coming above from the seat, from behind the walls, into the hole of the player’s ceiling. The app needs to know where these physical walls are. Both the enemies and the lasers interact with the walls and any other scene objects in the physical environment. So, if you shoot your desk or if the enemy shoots your desk, you see the bullet hole decals. Or if one of the drones crashes over a desk, it will fall and hit the desk.
This logic uses Discover’s integration of the Scene API. The Scene API is used to spawn Photon network objects, and then everything is handled completely in the Discover level, like tracking and synchronizing the objects.
All these objects are also already set up at the Discover level to do all things necessary in all the full game experiences contained within Discover. Theoretically, you could swap these objects out depending on the app selection. For example, you don’t need the Interaction SDK’s RayInteractibles in DroneRage, because you are not pointing at the drones, but Discover has all these as a mega object because it’s easier than creating and de-spawning objects.
Adding scene to DroneRage
The SceneElement class can be found in /Assets/Discover/Scripts/SceneElement.cs and SceneElementsManager in /Assets/Discover/Scripts/SceneElementsManager.cs.
To enable DroneRage access to Scene elements, the objects first need to be registered with a Scene Elements Manager in the Awake function of the SceneElement class:
private void Awake()
{
m_highlightObject.SetActive(false);
SceneElementsManager.Instance.RegisterElement(this);
}
Let’s take a look at Unity Editor to better understand how this Scene API integration works. This is the DiscoverAppController prefab.
the discoverappcontroller prefab in unity is displayed with several fields like scene manager and colocation prefab filled in
In its hierarchy, it has an OVRSceneManager which is part of the built-in Meta XR Core SDK.
the hierarchy view in unity editor has the OVRSceneManager highilghted
OVRSceneManager uses the Scene API from the Unity Editor’s perspective.
the OVRSceneManager is selected in the Unity's Editor's Inspector
When a ceiling object is detected by the Scene API, it spawns the CeilingPhotonInstantiator object.
The CeilingPhotonInstatiator object selected in Unity's Editor inspector
Although indirect, it has an OVR Scene Anchor class, which is required by OVRSceneManager so that it can be tracked. This uses the Photon Instantiator component which is part of Discover and instantiates this network object.
Unity Editor inspector with the Photon Instantiator script selected
The reason for that is that it instantiates network objects through Photon Fusion, rather than using Object.Instantiate. Then, there is the SceneCeilingPhoton class which is a Photon Fusion net object.
Unity Editor with the SceneCeilingPhoton object selected
This has the Scene Element component. This is a Discover class, which means the Scene Element Manager tracks it automatically. Since it’s a network object, the colocated player automatically spawns that object because it’s a Photon Fusion network object. This is not special in terms of Scene API or colocation. Rather, it’s like any other network GameObject.
Scene Elements
In the SceneElementsManager class, in /Assets/Discover/Scripts/SceneElementsManager.cs, there is this line:
public IEnumerable<SceneElement> GetElementsByLabel(string label) =>
Instance.SceneElements.Where(e => e.ContainsLabel(label));
That label is a string (such as “CEILING”, and so on). You can see, for example, in class EnvironmentSwapper of DroneRage in /Discover/DroneRage/Scripts/Scene/EnvironmentSwapper.cs how it changes the materials of the walls:
private async void SwapWalls(bool toAlt)
{
await UniTask.WaitUntil(() => SceneElementsManager.Instance.AreAllElementsSpawned());
foreach (var wall in SceneElementsManager.Instance.GetElementsByLabel(OVRSceneManager.Classification.WallFace))
{
if (toAlt)