hi ther guys first thanks for those who read and answer my quesions β¦!! ![]()
now the isue i have is this:
so i network.instantiate my player o the level like this in the OnNetworkLoadedLevel function that comes with unity:
void OnNetworkLoadedLevel ()
{
int SpawnIndex = Random.Range(0, respawns.Length);
GameObject this_player = Network.Instantiate(Player,
respawns[SpawnIndex].transform.position,
Quaternion.identity, 0) as GameObject;
this_player.GetComponent<IsRemotePlayer>().UserName = this_player_nametag;
}
UserName and this_player_nametag are strings but as you can se UserName is on a script attached to the player prefab i instantiate
, the isue is here on this line:
this_player.GetComponent().UserName = this_player_nametag;
it gives me this error on console:
NullReferenceException: Object reference not set to an instance of an object
β so the question is why s this happening? i call properly the OnNetworkLoadedLevel() and even the player prefab spawns and sete everything properly, but the error that display the console is like there was no player gameobject at all right??
plz help me with thisβ¦!!