public void CreatePlayer(string ip, string name, JsonData robotStructure, string hexColor) { if (enemyPrefab == null) { throw new UnityException("Enemy prefab is missing!"); } Debug.Log("creating player " + name); //GameObject obj = Instantiate(enemyPrefab) as GameObject; GameObject obj = Instantiate(enemyPrefab, spawnPointGenerator.RandomSpawnPoint(), Quaternion.identity) as GameObject; //obj.transform.position = spawnPointGenerator.RandomSpawnPoint(); EnemyController player = obj.GetComponent <EnemyController>(); player.SetUserId(ip); player.SetName(name); //player.SetColor(hexColor); int top = Int32.Parse(robotStructure["TOP"].ToString()); int bottom = Int32.Parse(robotStructure["BOTTOM"].ToString()); int left = Int32.Parse(robotStructure["LEFT"].ToString()); int right = Int32.Parse(robotStructure["RIGHT"].ToString()); player.InitEquipment(top, left, right, bottom); }
// Use this for initialization void Start() { anim = GetComponent <Animator>(); controller = GetComponent <CharacterController>(); transform.position = spawnPointGenerator.RandomSpawnPoint(); timeStamp = Time.time + 0.3f; /* * //obj_Robo01_ * foreach (Transform child in transform) * { * Debug.Log("Iterating on child: " + child.name); * if (child.name == "obj_Robo01_") * { * Debug.Log("Changing color to robot: " + color); * child.GetComponent<Material>().SetColor("_MaskColor", HexToColor(color)); * } * * } */ }