Instantiate different avatar for each player
How do I instantiate a different avatar for each connected player?
3 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 instantiate a different avatar for each connected player in NormalVR, you can use the
RealtimeAvatarManager
component. This component is responsible for instantiating an avatar prefab to represent the local player and keeping track of avatars that were instantiated for other players in the same room.
If you want to use a different avatar prefab for different clients, you can change the localAvatarPrefab
property at runtime from your own scripts. This property represents the avatar prefab that will be instantiated to represent the local client. The prefab needs to include a RealtimeAvatar
component on the root in order to function correctly.
Here is an example of how you can use the RealtimeAvatarManager
:
In this example, the AvatarCreated
and AvatarDestroyed
methods are event handlers that get called when a player joins or leaves the room, respectively. You can add your own logic inside these methods to handle these events as needed.
For more information, you can refer to the RealtimeAvatarManager documentation (https://normcore.io/documentation/realtime/xr/avatars#realtimeavatarmanager).
----------------------
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 us know how it did by reacting below
If you want a different prefab to be instantiated per player you'll need to make a custom avatar manager like the bot says.
If you just want to change the materials you can add an array of materials to the avatar prefab and switch between them based on client ID