How to use getcomponent with a namespace?

Hi

Im currently making a multiplayer racing game and I need to use the getcomponent code in my script. I am trying to get this script from Unity’s car in the Vehicles package that can be downloaded in the standard assets. However, the two car scripts im trying to get, CarController and CarUser control both have namespaces which are namespace UnityStandardAssets.Vehicles.Car

I have never come accross namespaces before so I dont really know how to use them. I looked up the documentation and created this code

using UnityEngine;
using System.Collections;
namespace StandardAssets.Vehicles.Car

public class NetworkPlayer : MonoBehaviour {

    public GameObject Mycamera; //Mycamera to follow cars

    void Start () {
        Mycamera.SetActive(false); //Dont set active
        GetComponent<CarController>().enabled = true; // enable them when multiplayer starts
        GetComponent<CarUserControl>().enabled = true;
    }
    
    // Update is called once per frame
    void Update () {
    
    }
}

However this code gives me the errors :

Assets/Network/NetworkPlayer.cs(5,6): error CS1003: Syntax error, `.’ expected

Assets/Network/NetworkPlayer.cs(5,44): error CS8032: Internal compiler error during parsing, Run with -v for details

Any help would be appreciated as I’m really stuck here.

Thanks in Advance

Dok

A namespace is just a closed location where classes are stored. using namespaces allows the developer to make some classes/variables/methods as internal. This way, they are accessible all over the namespace like public but hidden from outside the namespace.

In your case, you would get the component just as usual. Think of it like when you use the UnityEngine.UI.

Either you add on top :

 using MyNamespace;

this means the compiler will link the namespace to that script and allows the user to access all public items. Consider you MyComponent inside MyNamespace:

using MyNamespace;
public class MyClass:MonoBehaviour{
     void Start(){
        var comp = GetComponent<MyComponent>();
     }
}

The other way is to explicitly address the component:

public class MyClass:MonoBehaviour{
     void Start(){
        var comp = GetComponent<MyNamespace.MyComponent>();
     }
}

this may be compulsory if two different namespaces contain a MyComponent class and the compiler is not able to define which you meant.