public static TeamPlayer CreateComponent(GameObject gameObject, Team team) { TeamPlayer tp = gameObject.AddComponent <TeamPlayer>(); tp.Team = team; return(tp); }
void OnTriggerEnter(Collider other) { GameObject player = other.gameObject; // Ugly hack Transform parent = other.transform.parent; if (parent != null) { player = parent.gameObject; } if (player.CompareTag("Player")) { TeamPlayer.CreateComponent(player, team); var renderers = player.GetComponentsInChildren <Renderer>(); foreach (Renderer r in renderers) { r.material = teamColor; } CmdTeleportToTeamCastle(player.GetComponent <NetworkIdentity>().netId); } }