Getting normcore to work with XR Interaction Toolkit & creating trackable objects
Hello, I'm creating a multiplayer game where players navigate their own boats and shoot balls at each other. I have gotten multiplayer to build to a standalone apk for Quest, yet can't figure out how to get players items to track to each player's Local Avatar Prefab. Do I need to add a component to all the prefab's children? Any links to resource? - Should I be following Strokebrush and reprogram my boat/ oars/ XRI hands/head? Thanks for any help- this is for my capstone at school ❤️
10 Replies
Hi @nonnapasta. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To get players' items to track to each player's Local Avatar Prefab in Normcore, you'll need to set up your avatar prefab correctly and use RealtimeTransform components. Here's a general approach based on the information from the Normcore documentation:
1. Set up your avatar prefab:
Follow the guide on XR Avatars and Voice Chat to create a custom avatar prefab. This will give you a basic structure for your player avatar.
2. Add RealtimeTransform components:
For each object that needs to be synchronized (boat, oars, hands, head), add a RealtimeTransform component. This component will handle the synchronization of position, rotation, and scale across the network.
3. Ownership:
Make sure the root RealtimeView of your player prefab is owned by the local player. This ensures that only the local player can modify their avatar and associated objects. The Ownership and Lifetime Flags documentation explains this concept in detail.
4. Hierarchy:
Organize your player prefab hierarchy so that all synchronized objects are children of the root RealtimeView. This way, ownership settings will apply to all child objects automatically.
5. XR Interaction Toolkit integration:
While there's no specific documentation on integrating XR Interaction Toolkit with Normcore, you can use RealtimeTransform components on your XRI hands and head to synchronize their positions and rotations.
For your boat and oars, you might need to create custom RealtimeComponents if they have specific behavior that needs to be synchronized beyond just transform data. The Synchronizing Custom Data guide can help you with this process.
Regarding the Strokebrush example, while it provides a good reference for synchronizing objects, you don't necessarily need to reprogram everything to follow that exact pattern. Instead, focus on using RealtimeTransform components for basic synchronization and create custom RealtimeComponents for more complex behaviors.
Unfortunately, the provided knowledge sources don't contain specific information about integrating XR Interaction Toolkit with Normcore. You might need to experiment with combining the two systems, ensuring that XRI handles local interactions while Normcore handles network synchronization.
For more detailed guidance, I recommend checking out these resources:
- Creating a Player Controller
- RealtimeTransform documentation
Remember to test your implementation thoroughly in multiplayer scenarios to ensure smooth synchronization across different clients.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@346140392225374208> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
You should add a Realtime Transform to every object you want to sync and then use RequestOwnership on RT that you pick up. You can do that with the XRI events
also use Realtime.Instantiate if you want to instantiate anything that's synced duing runtime
for normcore assisstant: what is the RealtimeView do? @Normcore Assistant
for normcore assisstant: what is the RealtimeView do? @Normcore Assistant
Let me check the knowledge base for you again. One moment! :books:
----------------------
RealtimeView is a crucial component in the Normcore framework for Unity. Here's a concise explanation of what RealtimeView does:
RealtimeView is a component that identifies and manages game objects and their associated RealtimeComponents across multiple clients in a networked application. Its main functions include:
1. Identification: It creates a unique identifier for game objects, allowing them to be recognized across different clients.
2. Model Management: RealtimeView creates and manages models for each RealtimeComponent on the game object, storing them in the Normcore datastore for synchronization.
3. Hierarchy Management: It handles parent-child relationships between game objects, ensuring that ownership and synchronization settings are properly applied throughout the hierarchy.
4. Ownership Control: RealtimeView manages ownership of the game object, determining which client has the authority to modify its state.
5. Lifetime Management: It controls the persistence of objects between sessions and their destruction when clients leave the room.
According to the RealtimeView documentation, "When a prefab is instantiated, RealtimeView creates a model for each RealtimeComponent on the prefab and puts it into the datastore. Then, when the prefab is instantiated on other clients, RealtimeView will connect the model in the datastore with its respective RealtimeComponent on the prefab."
This component is essential for creating synchronized multiplayer experiences in Normcore, as it forms the foundation for object replication and state synchronization across the network.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@346140392225374208> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
I'm struggling setting up a local avatar prefab that will synch across headsets & moves. it holds a boat, a player w/ hands, and two oars @Normcore Assistant
Let me check the knowledge base for you again. One moment! :books:
----------------------
I understand you're having difficulties setting up a local avatar prefab that synchronizes across headsets and includes a boat, a player with hands, and two oars. Let's break this down using Normcore's documentation to guide you through the process:
1. Create your avatar prefab:
Start by creating a custom avatar prefab as described in the XR Avatars and Voice Chat guide. This will give you a basic structure for your player avatar.
2. Set up the hierarchy:
Organize your prefab hierarchy with the boat, player, hands, and oars as child objects of the root avatar object. This ensures proper ownership and synchronization.
3. Add RealtimeView:
Add a RealtimeView component to the root of your avatar prefab. This is crucial for identifying and managing your avatar across clients.
4. Add RealtimeTransform components:
For each object that needs to be synchronized (boat, player, hands, oars), add a RealtimeTransform component. This will handle the synchronization of position, rotation, and scale across the network.
5. Configure the RealtimeAvatarManager:
In your scene, make sure you have a RealtimeAvatarManager component set up. According to the RealtimeAvatarManager documentation, "RealtimeAvatarManager is a component that lives in the scene on the same game object as your Realtime instance. It is responsible for instantiating an avatar prefab to represent the local player as well as keeping track of avatars that were instantiated for other players in the same room."
6. Set the Local Avatar Prefab:
In the RealtimeAvatarManager component, assign your custom avatar prefab (the one with the boat, player, hands, and oars) to the "Local Avatar Prefab" field.
7. Ownership:
Ensure that the RealtimeView on your avatar prefab is set to be owned by the local client. This can be done by setting
ownedByClient: true
when instantiating the prefab, or by calling RequestOwnership()
on the RealtimeView after instantiation.
Here's a snippet of how your avatar script might look:
Remember to create a corresponding CustomAvatarModel
that extends RealtimeModel
to define the properties that need to be synchronized.
If you're still facing issues, you might want to check the Creating a Player Controller guide for more detailed information on player movement and control.
Lastly, make sure to test your implementation thoroughly in a multiplayer setting to ensure smooth synchronization across different clients.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@346140392225374208> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
make sure you request ownership of the boat and ore when you spawn your avatar