Avatar sync
I have a 4 player game in VR, when an avatar syncs to other players I want to place them in differente positions depending where all the players are, I have a table and I want to place them on each side of that table.
5 Replies
Hi @fgamez1020. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To implement avatar synchronization with custom positioning in your 4-player VR game using NormalVR, you can utilize the
RealtimeAvatarManager
component along with some custom logic. Here's an approach you can take:
1. First, set up your avatar system using the RealtimeAvatarManager
as described in the Avatars documentation (https://normcore.io/documentation/realtime/xr/avatars#realtimeavatarmanager).
2. Create a script to manage the positioning of avatars around your table. This script should:
- Keep track of available positions around the table
- Assign positions to avatars as they join
- Update positions if players leave
3. Use the avatarCreated
event from RealtimeAvatarManager
to detect when new avatars join and position them accordingly.
Here's a basic example of how you might implement this:
This script assumes you have an array of Transform
objects representing the positions around your table. It assigns each new avatar to an available position and keeps track of which positions are occupied.
Remember to add this script to the same GameObject as your RealtimeAvatarManager
and set up the tablePositions
array in the Inspector.
Note that this is a basic implementation and you might need to adjust it based on your specific requirements, such as handling cases where more than 4 players try to join or implementing more sophisticated positioning logic.
For more advanced avatar customization, you can refer to the Modifying RealtimeAvatar scripts (https://normcore.io/documentation/realtime/xr/avatars#modifying-realtimeavatar-scripts) section of the documentation.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1053407831916822528> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
but for example, my avatar should show where I am, but my synced avatar should show to the other players in a different position to where they are
@kapa.ai but for example, my avatar should show where I am, but my synced avatar should show to the other players in a different position to where they are
Let me check the knowledge base for you again. One moment! :books:
----------------------
I understand you want to display your avatar in different positions for yourself and other players. This is an interesting scenario that requires some custom logic on top of Normcore's avatar system. Let's break this down:
1. For your local view, you want your avatar to represent your actual position in the VR space.
2. For other players, you want your avatar to appear at a predetermined position (e.g., around a table).
To achieve this, we can modify the approach using Normcore's
RealtimeAvatar
component. Here's how you might implement this:
1. First, set up your avatar prefab with a RealtimeAvatar
component as described in the RealtimeAvatar documentation (https://normcore.io/documentation/realtime/xr/avatars#realtimeavatar).
2. Create a custom script to manage the avatar positioning. This script should:
- Keep the local avatar at the player's actual position
- Position remote avatars at predetermined locations
Here's a basic example of how you might implement this:
This script does the following:
1. It only positions remote avatars (non-local) at predetermined table positions.
2. The local avatar is left untouched, so it will represent the player's actual position in VR space.
3. Remote avatars are kept at their assigned positions in the Update
method to ensure they don't move from their predetermined spots.
To use this script:
1. Attach it to the same GameObject as your RealtimeAvatarManager
.
2. Set up the tablePositions
array in the Inspector with Transform objects representing the positions around your table.
Remember, this is a basic implementation. You might need to adjust it based on your specific requirements, such as handling cases where more players join than available positions, or implementing more sophisticated positioning logic.
For more advanced avatar customization, you can refer to the Modifying RealtimeAvatar scripts (https://normcore.io/documentation/realtime/xr/avatars#modifying-realtimeavatar-scripts) section of the Normcore documentation.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------if you want to fake your position I wouldn't use RealtimeTransform and just read how many players are in the scene locally and place avatar dummies where ever you want
or you can put the remote avatars as children of the seats around the table
RealtimeTransform doesn't support reparenting out of the box so you'll have to sort out a custom solution