Player respawns on every client join

Options
I'm having this problem where players will respawn at spawn points every time a new player joins the room. This should happen only when they join, which it does. It also happens in a respawn RPC, but that isn't called until a player has already died. Any ideas why this happens?

In the start function
void Start()
		{
			if (photonView.IsMine)
			{
				SetPlayerTeam(gameInst.specString);
				transform.position = GameManager.instance.spawnPoints[Random.Range(0, GameManager.instance.spawnPoints.Length)].position;
				transform.rotation = GameManager.instance.spawnPoints[Random.Range(0, GameManager.instance.spawnPoints.Length)].rotation;
			}
		}

In the respawn RPC
void RespawnRPC()
		{
			SetRagdoll(false);

			if (photonView.IsMine)
			{
				transform.position = GameManager.instance.spawnPoints[Random.Range(0, GameManager.instance.spawnPoints.Length)].position;
				transform.rotation = GameManager.instance.spawnPoints[Random.Range(0, GameManager.instance.spawnPoints.Length)].rotation;

				if (!playerProperties.ContainsKey("state"))
				{
					playerProperties.Add("state", "alive");
				}
				playerProperties["state"] = "alive";
				PhotonNetwork.LocalPlayer.SetCustomProperties(playerProperties);
			}

			Cursor.lockState = CursorLockMode.Locked;
			Cursor.visible = false;
		}

Comments

  • jacksebben
    Options
    Edit: Each player should only be moved to a spawnpoint every time they join a room. If any new player joins and spawns, any existing players are teleported to a spawnpoint (as if it is their first time joining). I've tried checking for local photon views, but that doesn't work. I've tried figuring out where the respawn comes from, but I can't pinpoint it. It seems that each players' Start() function runs twice, but that doesn't make any sense.
  • jeanfabre
    Options
    Hi,

    can you put a debug log in your start function and check from where it's being called? this will likely shade some light as to what really happens.

    Bye,

    Jean
  • The start function is called from the same player on the same client

    PTVksbo.png

    Below is the debug code
    Debug.Log("Called in Start from player " + PhotonNetwork.LocalPlayer.NickName + " and object " + gameObject.name);
    

    Confusing, but 'yackseb' is the name of the local player, proven here:

    nJ3f2mC.png

    The gameobject name is changed for the player.
  • jeanfabre
    Options
    Hi,

    Good, now the question now is to look inside these two logs and see what code initiated the start() method.

    - are you using some pooling system on top of pun?
    - are you using pun classic or pun 2?

    Bye,

    Jean
  • jacksebben
    Options
    I am not using any other pooling system and I am using PUN 2.

    Thanks.
  • jacksebben
    Options
    I also want to show some updated logs (if these help)

    IHcPZtw.png

    "SPAWNED" Log:
    Runs in the player controller start function under photonView.isMine

    "Properties changed" Log:
    Runs in OnPlayerPropertiesUpdate function in a game manager
  • jeanfabre
    Options
    Hi,

    can you check for these two property changes what is the path of code? where does they originate from? same with the debug logs.

    Bye,

    Jean