Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    Dismiss Notice

Help Wanted Why is "type or namespace not found"

Discussion in 'Editor & General Support' started by KOpp0t, Jan 22, 2022.

  1. KOpp0t

    KOpp0t

    Joined:
    May 31, 2020
    Posts:
    30
    I am making a script that enables or disables the Unity Standard Assets FirstPersonController script on button click. I am getting the error "cs0246 the type or namespace FirstPersonController could not be found". I know that normally happens when you are missing a direcutive but the script is attacked to the same GameObject as the FirstPersonController script and im getting the error, have i dont something wrong?
    heres my code

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. public class StopMouse : MonoBehaviour
    5. {
    6.     // Update is called once per frame
    7.     void Update()
    8.     {
    9.         if(Input.GetKeyDown(KeyCode.Tab))
    10.         {
    11.             GetComponent<FirstPersonController>().enabled = false;
    12.         }
    13.         else
    14.         {
    15.             GetComponent<FirstPersonController>().enabled = true;
    16.         }
    17.     }
    18. }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    24,934
unityunity