Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Third Party Trying to use Photon Pun for Multiplayer

Discussion in 'Multiplayer' started by ArchDud3, Jul 9, 2023.

  1. ArchDud3

    ArchDud3

    Joined:
    Jun 27, 2023
    Posts:
    4
    Hi, I've been trying to add multiplayer to my game using Photon Pun, and I am currently trying to make the player join the room when they press join. I have
    public void OnClick() {
    Launcher.Instance.JoinRoom(info.name);
    }

    but an error pops out saying
    cannot convert from 'string' to 'Photon.Realtime.RoomInfo'

    Here is my full code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Photon.Realtime;
    5. using Photon.Pun;
    6. using TMPro;
    7.  
    8. public class RoomListItem : MonoBehaviour
    9. {
    10.     [SerializeField] TMP_Text text;
    11.  
    12.     RoomInfo info;
    13.  
    14.     public void SetUp(RoomInfo _info) {
    15.         text.text = _info.name;
    16.     }
    17.  
    18.     public void OnClick() {
    19.         Launcher.Instance.JoinRoom(info.name);
    20.     }
    21. }
    22.  
     
  2. Lukeesta

    Lukeesta

    Joined:
    Jan 7, 2016
    Posts:
    68
    As the error says you want to pass in the full info and not just the name of the info.
    Launcher.Instance.JoinRoom(info);
     
    Munchy2007 likes this.