- Home /
The type or namespace name `RigidbodyFirstPersonController' could not be found?
can anyone suggest why my code is not recognizing the component in this snippit of code?
public class gameController : MonoBehaviour {
public GameObject[] characters;
public int charSelect = 0;
public GameObject curCharacter;
// Use this for initialization
void Start () {
curCharacter = characters[charSelect-1];
}
// Update is called once per frame
void Update () {
//if select character 1
if (curCharacter != characters[0])
{
if (Input.GetKeyUp (KeyCode.Alpha1)) {
Debug.Log("Switching to Character 1");
Debug.Log (curCharacter.transform.GetChild (1));
//cease control of current character
curCharacter.transform.GetChild (0).gameObject.SetActive (false);
Component control = curCharacter.GetComponent<RigidbodyFirstPersonController>();
control.enabled = false;
}
}
the exact error is
Assets/000_GameController/gameController.cs(27,79): error CS0246: The type or namespace
name `RigidbodyFirstPersonController' could not be found. Are you missing
a using directive or an assembly reference?
This is a script currently on the game object.
Ensure that you have a RigidbodyFirstpersonController to the object you're trying to obtain it from... and also change the "Component" reference to be RigidbodyFirstPersonController. Give that a go and see.
It can't find the script 'RigidbodyFirstPersonController', double check if you have the script in your assets, or if it is under a namespace.
yes RigidbodyFirstPersonController is on the object im trying to obtain it from, honestly this is the standard prefab from the standard assets. as for changing the component reference, its still unrecognized.
Answer by robert_southee · Mar 18, 2015 at 11:31 PM
It is under a namespace
UnityStandardAssets.Characters.FirstPerson.RigidbodyFirstPersonController
You can either type that out in the GetComponent or at the top of your script add
using UnityStandardAssets.Characters.FirstPerson
thank you, i couldn't remember what a namespace was. it has been a long while since ive learned this.