I’m just beginning to learn networking, …
I did read all the unity reference:
http://docs.unity3d.com/Documentation/Components/NetworkReferenceGuide.html
and I couldn’t figure out a thing how to even start, …
than I followed this on youtube till step 4
but I want it to work separatly (server script and client script)
and I get an error, but I can connect to server ok.
MissingComponentException: There is no 'NetworkView' attached to the "_Networking" game object, but a script is trying to access it.
You probably need to add a NetworkView to the game object "_Networking". Or your script needs to check if the component is attached before using it.
I have server/client attached to empty GO _Networking,
for server I disable client script and build & run it.
for client I activate client and disable server script and run it under unity it self, but change color button produces me an error.
where am I going wrong?
both scripts:
Server
using UnityEngine;
using System.Collections;
public class Server : MonoBehaviour {
public GameObject Planet;
public string IP = "127.0.0.1";
public int Port = 25001;
void OnGUI (){
if (Network.peerType == NetworkPeerType.Disconnected){
if (GUILayout.Button("Start Server")){
Network.InitializeServer(10, Port);
}
}
else {
if (Network.peerType == NetworkPeerType.Server){
GUILayout.Label("Server");
GUILayout.Label("Connections: " + Network.connections.Length);
if (GUILayout.Button("Logout")){
Network.Disconnect(5);
}
}
}
}
[RPC]
void ChangeColor (){
Planet.renderer.material.color = Color.green;
}
}
Client
using UnityEngine;
using System.Collections;
public class Client : MonoBehaviour {
public GameObject Planet;
public string IP = "127.0.0.1";
public int Port = 25001;
void OnGUI (){
if (Network.peerType == NetworkPeerType.Disconnected){
if (GUILayout.Button("Start Client")){
Network.Connect(IP,Port);
}
}
else {
if (Network.peerType == NetworkPeerType.Client){
GUILayout.Label("Client");
if (GUILayout.Button("Change collor")){
networkView.RPC("ChangeColor", RPCMode.All);
}
if (GUILayout.Button("Logout")){
Network.Disconnect(5);
}
}
}
}
[RPC]
void ChangeColor (){
Planet.renderer.material.color = Color.green;
}
}
thanks in advance just a gently push in right direction will be nice, …