I instantiate an object using the following line:

obj_player = PhotonNetwork.Instantiate(prefab_obj_player.name, transform.position, Quaternion.identity);

Right after that line, I put this:

obj_player.GetComponent<script_playerTudo>().online = true;

The value of this variable does not change. And it's not just in this case, I'm not able to change variable values ​​within object scripts that I instantiate by Photon.

What's happening? It's a basic reference, offline it works perfectly.

  • \$\begingroup\$ Where do you change them? On the server or the client? And where is it not updated? When you update it on server -> not visible on client or update on client -> not visible on server? \$\endgroup\$
    – Zibelas
    Nov 13, 2022 at 12:57
  • \$\begingroup\$ @Zibelas When I run the game on mobile, the player that should have a variable with the value true, becomes false, as if this line had not counted. Same thing when I create a shot, and I try to define this player (client) as the owner of that shot... The shot has no owner. \$\endgroup\$ Nov 13, 2022 at 14:42
  • \$\begingroup\$ Is your gameObject in the PhotonNetwork.PrefabPool? Do you have a PhotonView on your prefab? \$\endgroup\$
    – Zibelas
    Nov 13, 2022 at 14:53
  • \$\begingroup\$ @Zibelas yes, the only thing that says is that I can't set values ​​in the script contained in this prefab instantiated by ´PhotonNetwork.Instantiate´. \$\endgroup\$ Nov 13, 2022 at 15:03


You must log in to answer this question.

Browse other questions tagged .