0
\$\begingroup\$

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)
    {
        Debug.Log("yo");
        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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.