여기에서 버튼 클릭으로 클라이언트에서 Player를 인스턴스화하려고합니다. 여기에 내 대본이있다. 클라이언트의 서버는 볼 수 있지만 서버의 클라이언트 플레이어는 볼 수 없습니다. 누구든지 도울 수 있습니다.?클라이언트 플레이어가 서버 유니티에 표시되지 않음 5
나는 사용자 지정 스크립트로 플레이어를 인스턴스화합니다. 버튼 클릭 후 플레이어가 인스턴스화됩니다.
btnPlayer 버튼을 누르면 Player가 인스턴스를 생성합니다.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Networking;
using UnityEngine.UI;
public class Network_Manager_Custom : NetworkManager {
private Animator anim;
//[SerializeField]private GameObject btnDisconnect;
[SerializeField]private GameObject _player, SpawnPointsParent, btnPlayer;
[SerializeField]private List<GameObject> sPoints;
private bool checkState = false;
private int iPos = 0;
GameObject ga;
public void StartupHost()
{
setPort();
NetworkManager.singleton.StartHost();
sPoints = new List<GameObject>();
}
public void JoinGame()
{
setIPAddress();
setPort();
NetworkManager.singleton.StartClient();
iPos = iPos + 1;
}
public void setIPAddress()
{
string IPAddress = GameObject.Find ("InputFieldIPAddress").transform.FindChild("Text").GetComponent<Text>().text;
NetworkManager.singleton.networkAddress = IPAddress;
Debug.Log ("IPAddress : "+ IPAddress);
}
void setPort()
{
NetworkManager.singleton.networkPort = 7777;
}
void OnLevelWasLoaded(int level)
{
if (level == 0) {
SetupMenuScreenButtons();
} else {
SetupOtherSceneButtons();
}
}
void SetupMenuScreenButtons()
{
GameObject.Find ("btnStartHost").GetComponent<Button>().onClick.RemoveAllListeners();
GameObject.Find ("btnStartHost").GetComponent<Button>().onClick.AddListener (StartupHost);
GameObject.Find ("btnJoinGame").GetComponent<Button>().onClick.RemoveAllListeners();
GameObject.Find ("btnJoinGame").GetComponent<Button>().onClick.AddListener (JoinGame);
}
void SetupOtherSceneButtons()
{
//btnDisconnect = GameObject.Find ("btnDisconnect");
//if (btnDisconnect != null) {
GetListOfPlayer();
GameObject.Find ("btnDisconnect").GetComponent<Button>().onClick.RemoveAllListeners();
GameObject.Find ("btnDisconnect").GetComponent<Button>().onClick.AddListener (NetworkManager.singleton.StopHost);
GameObject.Find ("btnPlayer").GetComponent<Button>().onClick.RemoveAllListeners();
GameObject.Find ("btnPlayer").GetComponent<Button>().onClick.AddListener (PlayerInstantiateHere);
//} else {
// Debug.Log("btnDisconnect not available.!");
//}
}
void GetListOfPlayer()
{
if(SpawnPointsParent == null)
SpawnPointsParent = GameObject.Find ("SpawnPoints");
foreach(Transform t in SpawnPointsParent.transform)
{
sPoints.Add (t.gameObject);
}
}
public void PlayerInstantiateHere()
{
if (_player != null) {
//NetworkManager.Instantiate (_player, sPoints [iPos].transform.position, sPoints [iPos].transform.rotation);
GameObject ga = (GameObject) NetworkBehaviour.Instantiate(_player, sPoints [iPos].transform.position, sPoints [iPos].transform.rotation);
ClientScene.RegisterPrefab (ga);
NetworkServer.Spawn (ga);
}
Debug.Log ("Player button clicked.!");
}
}
좀 더 정의 할 수 있습니까? "클라이언트에서는 서버를 볼 수 있지만 서버에서는 클라이언트 플레이어를 볼 수 없습니다. 누구든지 도움을받을 수 있습니다." –
클라이언트에서 서버 플레이어를 볼 수 있지만 서버의 클라이언트 플레이어를 볼 수 없습니다. 그래서, 서버에서 오직 한 플레이어와 클라이언트 쪽 두 플레이어. 클라이언트 플레이어가 서버/호스트에 표시되지 않음 –
각 플레이어 카메라는 무엇이며 각 플레이어는 어디에서 산란합니까? 위치? –