public void CmdLoad() { NetworkLobbyInfo infoTmp = gameObject.GetComponent <NetworkLobbyInfo>(); GameObject spawnTmp = PlayableCharacters.instance.Spawns[infoTmp.lobbyIndex]; transform.position = spawnTmp.transform.position; transform.rotation = spawnTmp.transform.rotation; GameObject character = (GameObject)Instantiate(PlayableCharacters.instance.Characters[infoTmp.characterIndex], Vector3.zero, Quaternion.identity); // spawnTmp.transform.position, spawnTmp.transform.rotation); // character.name = PlayableCharacters.instance.Characters [infoTmp.characterIndex].name; character.transform.parent = gameObject.transform; // character.transform.position = transform.position; // character.transform.rotation = transform.rotation; // RpcSetChild (character.name); // RpcSetRotation(transform.rotation); // RpcSetPosition (transform.position); //GetComponent<NetworkTransform> ().enabled = false; GetComponent <NetworkTransformChild>().target = character.transform; Debug.Log("Destroying placeholder at " + gameObject.name); Transform placeholder = transform.FindChild("Placeholder"); placeholder.parent = null; Destroy(placeholder.gameObject); NetworkServer.Spawn(character); }
void Start() { NetworkLobbyInfo infoTmp = gameObject.GetComponent <NetworkLobbyInfo>(); childName = PlayableCharacters.instance.Characters[infoTmp.characterIndex].name; if (hasAuthority) { CmdLoad(); } }
// Used to pass variables from the lobby to the game public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { LobbyPlayer lobby = lobbyPlayer.GetComponent <LobbyPlayer>(); NetworkLobbyInfo info = gamePlayer.GetComponent <NetworkLobbyInfo>(); info.lobbyIndex = lobby.slot; Debug.Log("Lobby index = " + info.lobbyIndex); info.characterIndex = lobby.characterIndex; Debug.Log("Character index = " + info.characterIndex); info.playerName = lobby.playerName; Debug.Log("Name index = " + info.playerName); }
void Update() { if (!attached) { GameObject filho = GameObject.Find(childName + "(Clone)"); if (filho != null) { Debug.Log("so far so good!"); filho.transform.parent = transform; GetComponent <NetworkTransformChild>().target = filho.transform; attached = true; if (isServer) { filho.transform.rotation = transform.rotation; filho.transform.position = transform.position; } else { NetworkLobbyInfo infoTmp = gameObject.GetComponent <NetworkLobbyInfo>(); GameObject spawnTmp = PlayableCharacters.instance.Spawns[infoTmp.lobbyIndex]; transform.rotation = spawnTmp.transform.rotation; transform.position = spawnTmp.transform.position; } Transform placeHolder = transform.FindChild("Placeholder"); if (placeHolder != null) { placeHolder.parent = null; // transform.rotation = placeHolder.rotation; // transform.position = placeHolder.position; // Destroy(placeHolder.gameObject); } } } }