Hello there, I’d like to create a VR multiplayer game using Unity version 2022.3.5, XRI Toolkit version 2.4.3, and Normcore version 2.1. I intend to develop a system where, upon entering a room, players will spawn at specific points.
I have tried the code below, but I’m facing an issue where on my device, other players have spawned at the designated spawn point. However, on other players’ devices, they still spawn at the same point as me (origin). Is there a way to resolve this matter?
Here’s the code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Normal.Realtime;
public class PlayerSpawnManager : MonoBehaviour
{
public Transform spawnPoints; // Array untuk menyimpan titik spawn pemain lain
private RealtimeAvatarManager avatarManager; // Instance dari RealtimeAvatarManager
private void Start()
{
avatarManager = GetComponent<RealtimeAvatarManager>();
avatarManager.avatarCreated += SpawnPlayer;
}
private void SpawnPlayer(RealtimeAvatarManager avatarManager, RealtimeAvatar avatar, bool isLocalAvatar)
{
Transform spawnPoint = spawnPoints[Random.Range(0, spawnPoints.Length)];
RealtimeTransform realtimeTransform = avatar.GetComponent<RealtimeTransform>();
realtimeTransform.RequestOwnership();
realtimeTransform.transform.position = spawnPoint.position;
realtimeTransform.transform.rotation = spawnPoint.rotation;
}
}
I am still very new and not familiar with this, so I need your help!