/// <summary> /// Instantiates a new GameObject and gives it proper components for remote controlling. /// </summary> /// <param name="prefab">Prefab used as a base for the new GameObject.</param> /// <param name="player">Serialization data used in creation.</param> /// <returns>Instantiated GameObject.</returns> protected override GameObject InstantiateSlave(GameObject prefab, Player player) { GameObject go = GameObject.Instantiate(prefab, player.CurrentPosition, Quaternion.identity); NetworkSlave slave = go.AddComponent <NetworkSlave>(); slave.Rigidbody = go.GetComponent <Rigidbody>(); slave.UpdateState(player); return(go); }
/// <summary> /// Deserializes the state to the GameObject from <see cref="Player" /> object. /// </summary> /// <param name="data">Data to deserialize from.</param> /// <param name="gameObject">GameObject to update.</param> protected override void DeserializeState(Player player, GameObject gameObject) { NetworkSlave slave = gameObject.GetComponent <NetworkSlave>(); slave.UpdateState(player); }