- Home /
Question by
HuskyPanda213 · Aug 14, 2013 at 05:34 AM ·
playerbugnetwork
Player-Network-Bug
I have a bug in my game, the host can move around and stuff, but he controls himself and another player model-thing, but the client player can move and stuff too but he doesn't see anyone, please Help me!!!
Code:
var playerPrefab : GameObject;
var spawnObject : Transform;
var gameName : String = "level1";
private var refreshing : boolean = false;
private var hostData : HostData[];
function OnGUI () {
if(!Network.isClient && !Network.isServer) {
if (GUI.Button(Rect(10,10,200,40),"Start Server")) {
startServer();
}
if (GUI.Button(Rect(10,60,200,40),"Refresh Hosts")) {
Debug.Log("Refresh");
refreshHostList();
}
if(hostData) {
for(var i:int = 0; i<hostData.length; i++) {
if(GUI.Button(Rect(10,100 + (50 * i),200,40),hostData[i].gameName)) {
Network.Connect(hostData[i]);
}
}
}
}
}
function Update () {
if(refreshing) {
if(MasterServer.PollHostList().Length > 0) {
refreshing = false;
Debug.Log(MasterServer.PollHostList().Length);
hostData = MasterServer.PollHostList();
}
}
}
function startServer () {
Network.InitializeServer(32,25001, !Network.HavePublicAddress);
MasterServer.RegisterHost("ZombieGame_Unity3d_12368","Regular Zombies","This is A level");
}
function OnServerInitialized () {
Debug.Log("server initialized");
spawnPlayer();
}
function OnConnectedToServer () {
spawnPlayer();
}
function spawnPlayer () {
Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity, 0);
}
function OnMasterServerEvent(mse:MasterServerEvent) {
if(mse == MasterServerEvent.RegistrationSucceeded) {
Debug.Log("Registered Server");
}
}
function refreshHostList () {
MasterServer.RequestHostList("ZombieGame_Unity3d_12368");
refreshing = true;
}
Comment
Answer by Yokil · Aug 14, 2013 at 06:17 AM
At the start of the character controll script put this:
if (! networkView.is$$anonymous$$ine)
this.enabled = false;
I told you to read in order to understand how to use, try to look for some examples in the forum.
Your answer
Follow this Question
Related Questions
How do you locate a Network.player? 0 Answers
Problem with identifying players in network 1 Answer
Network.Connect Fails To Connect 0 Answers
Photon Player resets to 0,0,0 0 Answers
Needs help to instantiate camera as child of player 0 Answers