Issues when trying to teleport multiple players to different positions in PUN V1

I'm making a game where players are put onto plates and random events happen to the plates/players. I've gone through a multitude of different networking solutions like UNET, Mirror, Mirror+Steamworks P2P but none of them really worked well (main issue being not being able to join via IP) so I settled on Photon. After Punv2 just wouldn't work on my project (an error in PhotonEditor.CS) I just used Punv1 which is working perfectly for the most part.

The issue right now is that I'm trying to spawn players on their owned plates but they only spawn on the first plate despite each plate being owned by a player (each plate has a script that specifies which player 'owns' it. This is being set correctly). This only seems to happen when I try to test with a real player/client. If I create a fake player by just spawning in the prefab and then running it, both players will be moved to their correct plate so it seems to be a networking issue.

Here's the code responsible for moving the players to their plates.

foreach (GameObject plate in spawnedPlates)
{
//Here we loop through each plate, get the player assigned to it and move the player to that plate.
GameObject player = plate.GetComponent().assignedTo;
PlayerClientControl playerController = player.GetComponent(); // originally for UNET/Mirror. Left in incase I need it(had an RPC function that moved the player).

player.transform.position = plate.transform.position + new Vector3(0, 4, 0);
}


It seems they ARE being moved to the correct positions (or atleast, it's trying to move them to the correct position) via a debug print statement that prints where they are trying to be teleported to further cementing that this is a networking issue but I have no idea how to fix it.

I assume it's something to with host/client synchronization? If anyone could shed some light on this, that'd be great because I'm pulling my hair out over this.

What am I doing wrong?

Comments

  • If youre trying to set positions like that then it needs to be an RPC call to target all players, then decide if you want if buffered. You can also just observe a transform view component.