I have already found similar questions on stackexchange.com related to accessing variables from another object. But my question seems to have a slightly different context and the answers from those questions are not working.
I have the following (stripped off) scene comprising the standard FPS character:
Scene001
|
|--FPSController
|
|--FirstPersonCharacter
My (stripped off) Assets hierarchy is as follows (folders are enclosed with <> brackets):
<Assets>
|
|--<Scripts>
| |
| |--Action.cs
|
|--<Standard Assets>
|
|--<Characters>
|
|--<FirstPersonCharacter>
|
|--<Scripts>
|
|--FirstPersonController.cs
Now FirstPersonController.cs is attached to FPSController by default and Action.cs is attached by me to FirstPersonCharacter.
Excerpt from FirstPersonController.cs is as follows:
...
namespace UnityStandardAssets.Characters.FirstPerson
{
...
public class FirstPersonController : MonoBehaviour
{
...
private void GetCharacter()
{
GameObject _obj = GameObject.Find("FirstPersonCharacter");// ok here
Debug.Log(_obj.GetComponent<Action>); // error here, please see below
}
...
}
}
Excerpt from Action.cs is as follows:
public class Action: MonoBehaviour {
...
public static bool is_acted;
...
}
All I want is to access bool is_acted variable of Action.cs from FirstPersonController.cs.
Error is as follows:
Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/
FirstPersonController.cs(166,67):error CS0246: The type or namespace
name `Action' could not be found. Are you missing an assembly reference?
To me this seems to be a problem of namespace or folder location!!?
Any help is highly appreciated. Thanks in advance.