show other names

This commit is contained in:
brausjonas
2022-05-18 00:29:12 +02:00
parent 7e8e0a93f9
commit ee55664811
6 changed files with 232 additions and 1 deletions
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class World : MonoBehaviour
{
@@ -25,6 +26,7 @@ public class World : MonoBehaviour
[SerializeField] private GameObject deadScreen;
[SerializeField] private GameObject pauseScreen;
[SerializeField] private GameObject optionsScreen;
[SerializeField] private Camera camera;
private ChunkCoord lastPlayerChunkCoord = new ChunkCoord(0, 0);
//chunks
@@ -93,11 +95,16 @@ public class World : MonoBehaviour
if (playersToCreate.Count > 0)
{
byte id = playersToCreate.Dequeue();
string nameOther = client.GetPlayerName(id);
GameObject player = Instantiate(playerPrefab);
player.transform.position = new Vector3((int)player.transform.position.x,
GetHeight((byte)player.transform.position.x, (byte)player.transform.position.z) + 2,
(int)player.transform.position.z);
player.transform.SetParent(gameObject.transform);
Canvas canvas = player.GetComponentInChildren<Canvas>();
canvas.worldCamera = camera;
Text nameText = player.GetComponentInChildren<Text>();
nameText.text = nameOther;
otherPlayers.Add(id, player);
}