Hello,
I PhotonNetwork.Instantiate my player and seperately PhotonNetwork.Instantiate the controls (Canvas UI button, joystick for mobile game).
When 1 player is in the room alone all is fine.
When a player joins I get an error that the player controls already exist. This causes the original and newly joined character to lose all their controls (ie buttons/joystick don't work).
I tried combining the controls into the player prefab but since it's a canvas that didn't work.
How can I fix this?
Update:
This is what I do to find the controls to use in player script:
I PhotonNetwork.Instantiate my player and seperately PhotonNetwork.Instantiate the controls (Canvas UI button, joystick for mobile game).
When 1 player is in the room alone all is fine.
When a player joins I get an error that the player controls already exist. This causes the original and newly joined character to lose all their controls (ie buttons/joystick don't work).
I tried combining the controls into the player prefab but since it's a canvas that didn't work.
How can I fix this?
Update:
This is what I do to find the controls to use in player script:
void Start ()
{
m_PhotonView = GetComponent<PhotonView> ();
if( m_PhotonView.isMine == true )
{
FlyJoystick = GameObject.Find("FlyJoystickInstNet").GetComponent<ETCJoystick>();
FlyJoystick.onMove.AddListener( On_Move_Flyjoystick);
FlyJoystick.onMoveEnd.AddListener( On_Move_End_Flyjoystick);
landButton = GameObject.Find("landButtonInstNet").GetComponent<ETCButton>();
landButton.onUp.AddListener( On_LandButton_Up);
flyButton = GameObject.Find("flyButtonInstNet").GetComponent<ETCButton>();
flyButton.onUp.AddListener(On_FlyButton_Up );
fireButton = GameObject.Find("fireButtonInstNet").GetComponent<ETCButton>();
fireButton.onDown.AddListener(fireHandler );
ForceSlider = GameObject.Find("SliderInstNet").GetComponent<Slider>();
}
}