I'm very new to Photon, medium experience in Unity. I'm trying to implement a lobby where, once a player enters the room before the game starts, a player card pops up for them ie. just their picked username before joining the room. My code is below:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;

public class gameManagerScript : MonoBehaviourPunCallbacks

    enum gameState {Lobby, Intro, Nighttime, Voting, Reveal}
    gameState currentGameState;

    // Start is called before the first frame update
    void Start()
        currentGameState = gameState.Lobby;

    public override void OnPlayerEnteredRoom(Player newPlayer)
        GameObject playerCard = PhotonNetwork.Instantiate("PlayerPrefab", new Vector3(0, 0, 0), Quaternion.identity);
        playerCard.transform.parent = GameObject.Find("Canvas").transform;
        playerCard.transform.localPosition = new Vector3(-800, 400, 0);

I know the code works as I've put it in the start function. The function is on an empty GameObject called game manager. Is this the correct way to do this? I'm really new to photon so don't know if I'm missing a photon component or what. I have also tried onJoinedRoom. All help is welcomed.


You must log in to answer this question.

Browse other questions tagged .