- Home /
Unity doesn't recognize any definition for Network
I created a new project with the intent of learning how to create a server and connect to it but I have been stuck on the very first step:
if (Network.peerType == NetworkPeerType.Disconnected){
}
gives me an error CS0117 -error CS0117: Network' does not contain a definition for
peerType'
I checked the scripting manual and everything seems to be in order.
Anyone might know whats the problem? Do I need scripting assets?
Edit: same thing happened for Network.connect(), he has no definition for it
Do you have using UnityEngine;
at the top of your c#
file, as per the example on the documentation page?
It's also case-sensitive, although I think you know since you wrote everything else correctly, just wanted to be sure. You wrote Network.connect(), the method is Connect()
Answer by Mishnab · Apr 25, 2014 at 03:33 PM
My entire script
using UnityEngine; using System.Collections;
public class Network : MonoBehaviour {
public string IP= "127.0.0.1";
public int port=123;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
if (Network.peerType == NetworkPeerType.Disconnected){
}
}
}
The file you created is called 'Network' - you will have to rename it to something which doesn't conflict with the existing Network class I think.
Your answer
![](https://koobas.hobune.stream/wayback/20220613143552im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Client timeout disconnecting on local server and in internet match. 0 Answers
Syncing terrain over Network 0 Answers
Command method dont change variables on server 0 Answers
Creating a multiplayer game. 1 Answer
Need help with networking 1 Answer