Arex
Arex2mo ago

Spawn points on spawn player

I want to add custom spawn points (emg roundrobin) , how may I do? As changing position after Instantiate, doesn't change the position
3 Replies
kapa.ai
kapa.ai2mo ago
Hi @Arex. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- When using Normcore (NormalVR), simply changing the position of a player GameObject after calling Realtime.Instantiate() does not update the position across the network unless your client owns the RealtimeTransform component. This is because RealtimeTransform synchronizes the position from the owner to all other clients, and only the owner can set the position. How to implement custom spawn points (e.g., round-robin): 1. Determine the spawn point before instantiation:
Before calling Realtime.Instantiate(), select your desired spawn position (using your round-robin logic). 2. Set the position immediately after instantiation, as the owner:
After instantiating the player prefab (which should have a RealtimeTransform component), and since you are the owner (using ownedByClient: true), you can set the position directly. This will be synchronized to all clients.
// Example: Select a spawn position
Vector3 spawnPosition = GetNextSpawnPoint();

// Instantiate the player prefab
GameObject player = Realtime.Instantiate("Player", ownedByClient: true);

// Set the position immediately after instantiation
player.transform.position = spawnPosition;

// Example: Select a spawn position
Vector3 spawnPosition = GetNextSpawnPoint();

// Instantiate the player prefab
GameObject player = Realtime.Instantiate("Player", ownedByClient: true);

// Set the position immediately after instantiation
player.transform.position = spawnPosition;

Alternatively, you can use the SnapTo() method on RealtimeTransform to instantly move the player to the spawn point (recommended for networked objects):
// Snap to the new spawn position (must be owner)
player.GetComponent<RealtimeTransform>().SnapTo(spawnPosition);

// Snap to the new spawn position (must be owner)
player.GetComponent<RealtimeTransform>().SnapTo(spawnPosition);

This ensures the position is updated and synchronized across all clients, as long as you are the owner of the RealtimeTransform component RealtimeTransform extra notes. Important:
- Make sure you set the position (or call SnapTo) immediately after instantiation, before any other client can interact with the object. - Do not try to set the position on a RealtimeTransform you do not own; it will be overridden by the owner's state. If you follow this approach, your custom spawn logic (including round-robin) will work as expected in Normcore multiplayer environments. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@647452911567241217> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Mechabit
Mechabit2mo ago
note that you can't move other player's avatars (or change anything owned by another player) the easiest method of player spawn point position is to use the clientID as the index in an array of spawn points and have the players move themselves there on Start

Did you find this page helpful?