Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine.Networking;
- using UnityEngine;
- public class PlayerManager : NetworkBehaviour {
- GameObject Panel;
- public GameObject PlayerUnitPrefab;
- // Update is called once per frame
- void Update () {
- if (!isLocalPlayer)
- return;
- if (Input.GetKeyDown(KeyCode.Space)) {
- CmdSpawnPlayer(gameObject);
- }
- }
- [Command]
- void CmdSpawnPlayer(GameObject hospitalizedPlayer) {
- hospitalizedPlayer = Instantiate(PlayerUnitPrefab);
- NetworkServer.Spawn(hospitalizedPlayer);
- RpcSpawnPlayer(hospitalizedPlayer);
- }
- [ClientRpc]
- void RpcSpawnPlayer(GameObject player) {
- Panel = GameObject.Find("Panel");
- player.transform.SetParent(Panel.transform);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement