Character Selection for Users

gamerickster

New member
Hello, I am sorta new, can someone please point me to where I can create different characters that a user can select? I know how to create the characters for PUN. I want the user to select male or female characters.

Thank you for your time!
 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class characterselection : MonoBehaviour
{

private ExitGames.Client.Photon.Hashtable _myCustomProperties = new ExitGames.Client.Photon.Hashtable();
public void SelectCharacter(int index)
{
PlayerPrefs.SetInt("MyCharacter", index);
Debug.Log("Player prefs: " + PlayerPrefs.GetInt("MyCharacter"));
_myCustomProperties["ID"] = index;
PhotonNetwork.LocalPlayer.CustomProperties = _myCustomProperties;
}
}

this first code is used with UI, where you will have to specify a int for every character

using UnityEngine;
using Photon.Realtime;


public class CharacterSpawnManager : SpawnManagerBase
{
[SerializeField]
protected GameObject[] m_Characters;

protected override GameObject GetCharacterPrefab(Player newPlayer)
{

if (newPlayer.CustomProperties.ContainsKey("ID"))
{
int result = (int)newPlayer.CustomProperties["ID"];
Debug.Log("Character ID : " + result);
return m_Characters[result];
}
else
{
return m_Characters[0];
}
}
}

the second code is used in you game scene in empty game object, you will have a table where tp put you characters,
 
Top