So I am trying to change a variable on a player object by clicking a button using Unet. However, I am having trouble getting the instance of the player object. Is there a way to get the instance of a player from the Network Manager component? I can change the variable before the player connects but once they are connected I can no longer modify it.
Is there a way to do this?
I have a PlayerController script and all I basically want to do is change an integer on my player object based on a button press. I have tried referencing the gameObject attached to the script with gameObject
and this
. That doesn't seem to work and I have also tried player.GetComponent<PlayerController>().myInt
and that doesn't seem to change it either.
All of these methods work until I connect as a Host or client and then it just doesn't do anything once I am connected.