Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Help Wanted Exo - Photon PUN2 Joystick Multiplayer Issues

Discussion in 'Multiplayer' started by JohnnyCar, Jun 18, 2021.

  1. JohnnyCar

    JohnnyCar

    Joined:
    Aug 5, 2018
    Posts:
    7
    Hey guys and gals,

    I'm working on adding multiplayer to my game called "Exo! it's on the app store currently in version 0.0.2
    Check it out if you like:
    https://apps.apple.com/us/app/exo/id1572161366

    Well, I'm using the Joystick Asset:
    Joystick Pack by FENERAX STUDIOS

    I'm having an issue where have to "attach" the UI elements(in this case the joystick) to the player once it is created.

    Code (CSharp):
    1.     public GameObject avatar;
    2.     public override void OnJoinedRoom()
    3.     {
    4.         avatar = PhotonNetwork.Instantiate(Player.name, position, rotation);
    5.         SpaceShipControlls controller = avatar.AddComponent<SpaceShipControlls>();
    6.         controller.stick = joystick;
    7.     }
    I was wondering why something like this doesn't seem to work.
    I need to make sure that every player has his own SpaceshipControlls component added and that the joystick UI is attached to that component.

    I just can't seem to get it to work.
    I get strange behavior like
    Player 1 controlling Player 2
    and
    Player 2 controlling Player 1

    I have tried adding the IsMine boolean too,
    Code (CSharp):
    1. if(photonView.IsMine){
    2.               // stick controls here.
    3. }
    It only seems to be attaching the SpaceShipControlls component to MasterPlayer or Player 1 now.

    Please Help Thank you.
     
unityunity