Avatar not returning after taking headset on / off
When our users take of their headset during a session, and put it back on after sleep, the default Avatar does not show up.
12 Replies
Hi @Mikameel. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
This issue is related to NormalVR's avatar system and how it handles reconnections after a device goes to sleep. Based on the available knowledge sources, I don't have specific information about this exact scenario. However, I can provide some insights that might help troubleshoot the issue:
1. Avatar Instantiation: The RealtimeAvatarManager is responsible for instantiating and managing avatars. When a user connects to a room, it should instantiate an avatar prefab to represent the local player. If the avatar is not reappearing after the headset wakes up, it's possible that the connection to the room is not being properly re-established.
2. Ownership and Lifetime Flags: The avatar's persistence might be affected by ownership and lifetime flags. As mentioned in the Server Authority + Ownership + Lifetime Flags documentation, these flags control how long a model's state should be retained. If the avatar is set to be destroyed when the owner leaves, it might not reappear after a disconnection.
3. Reconnection Handling: The issue might be related to how your application handles reconnections after the device wakes up from sleep. You may need to implement custom logic to ensure that the avatar is properly reinstantiated or reactivated when the connection is re-established.
4. Checking Avatar Status: You can use the RealtimeAvatarManager's properties and events to check the status of avatars. The
localAvatar
property and the avatarCreated
and avatarDestroyed
events might be useful for debugging this issue.
To further investigate and potentially resolve this issue, you might want to:
1. Implement logging to track when the avatar is created, destroyed, and when the connection status changes.
2. Check if the Realtime connection is properly re-established after the device wakes up from sleep.
3. Ensure that the avatar's lifetime flags are set correctly for your use case.
4. Consider implementing custom logic to handle reconnections and avatar reinstantiation if necessary.
If the problem persists after trying these steps, I recommend reaching out to the Normcore community on their Discord for more specific assistance, as they might have encountered similar issues and can provide more targeted advice.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@365574199844274177> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
When you say avatar, are you talking about Meta Avatars? https://docs.normcore.io/guides/meta/meta-avatars-setup
Or just the player in your game
It was the player in the game, turns out it was really simple. When your headset goes to sleep, Normcore connection times out.
I had join room on start on, but if you rejoin you don’t automatically restart. So I used on application focus and hmd is presence imput to rejoin if not connected @NormalMark @kapa.ai
Let me check the knowledge base for you again. One moment! :books:
----------------------
Thank you for sharing your solution! It's great that you were able to resolve the issue. Your approach aligns well with how Normcore handles connections and reconnections. Let me break down your solution and provide some additional context based on the Normcore documentation:
1. Connection Timeout: You're correct that when a headset goes to sleep, the Normcore connection times out. This is part of Normcore's built-in behavior to manage inactive connections.
2. Join Room on Start: As mentioned in the Realtime documentation, the "Join Room On Start" option is indeed available in the Realtime component. However, as you discovered, this only applies when the application starts, not when it resumes from sleep.
3. Manual Reconnection: Your solution of using
OnApplicationFocus
and checking for HMD presence to trigger a rejoin is a smart approach. This allows you to manually handle the reconnection when the headset wakes up.
To implement this solution, you might have used something similar to the following logic:
This solution demonstrates a good understanding of Normcore's behavior and how to work with it in a VR context. It's a valuable approach that others facing similar issues might benefit from.
For future reference, if you encounter similar connection-related issues, you might find the Room documentation helpful, as it provides more details on managing connections and room states.
Thank you for sharing your solution with the community!
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@365574199844274177> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai how can I set different type of avatars depending on which device is joinin the session?
Let me check the knowledge base for you again. One moment! :books:
----------------------
To set different types of avatars depending on which device is joining the session, you can utilize the RealtimeAvatarManager component and modify its behavior. Here's how you can approach this:
1. First, you'll need to determine the device type at runtime. This could be done using Unity's built-in device detection or a custom method.
2. Then, you can modify the
localAvatarPrefab
property of the RealtimeAvatarManager before the avatar is instantiated.
Here's a basic example of how you might implement this:
This approach is based on the information provided in the Realtime > Xr > Avatars documentation, which states:
"If you would like to use a different avatar prefab for different clients, this property can be changed at runtime from your own scripts."
Remember that each avatar prefab must include a RealtimeAvatar component on its root to function correctly with the RealtimeAvatarManager.
Also, keep in mind that this method will only affect the local player's avatar. If you want to visually distinguish between different device types for all players in the session, you'll need to implement additional logic to communicate the device type to other clients and update the avatar appearance accordingly.
For more advanced customization, you might want to consider creating your own avatar management system by modifying the RealtimeAvatar scripts, as suggested in the documentation:
"Unity's UPM package manager will not let projects modify RealtimeAvatarManager or RealtimeAvatar, so if you would like to modify them (and we encourage you to do so), we recommend copying all ReatimeAvatar classes into your project under a new namespace. From there you will be able to make any changes required for your project."
This would allow you to implement more complex device-specific avatar logic if needed.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@365574199844274177> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai My PC prefab is just a cube. What components do I need to attach to it? Can I just put the cube on the PC camera and make sure I add a reltime view and a realtime transform?
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on the information provided in the knowledge sources, I can guide you on setting up a basic avatar prefab for your PC (desktop) player. While a cube can serve as a simple avatar, there are a few components you'll need to attach to make it work properly with Normcore. Here's what you need to do:
1. RealtimeView: Yes, you're correct that you need to add a RealtimeView component to the root of your prefab. This is essential for any object that needs to be synchronized across the network.
2. RealtimeTransform: You're also correct about adding a RealtimeTransform component. This will synchronize the position, rotation, and scale of your cube avatar across the network.
3. RealtimeAvatar: In addition to the components you mentioned, you'll need to add a RealtimeAvatar component to the root of your prefab. This is crucial for the avatar system to work properly.
As stated in the Realtime > Xr > Avatars documentation:
"All avatar prefabs that are used with RealtimeAvatarManager need to include a RealtimeAvatar component on the root of the prefab."
While attaching the cube directly to the PC camera might work for a very basic setup, it's generally better to create a separate prefab for your avatar. This allows for more flexibility and easier management of different avatar types.
Here's a simple structure you might use for your PC avatar prefab:
Remember to place this prefab in a Resources folder so it can be instantiated at runtime by Normcore.
After setting up your prefab, you'll need to assign it to the RealtimeAvatarManager's
localAvatarPrefab
property, either in the inspector or at runtime as shown in the previous answer.
This basic setup should allow your cube avatar to be instantiated and synchronized across the network for PC players. However, keep in mind that for a more complete avatar system, you might want to add additional features like head and hand tracking, even for PC players, to improve interaction capabilities in your multiplayer environment.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@365574199844274177> Kapa.ai is still learning and improving, please let me know how I did by reacting below.