- Home /
Script reference from another c# script
I know there are a ton of those answers on this and I tried so far to follow these, but for some reason the variable _axis from the Joystick.cs can not be called from the following c# script.
CharacterMovement.cs:
private Vector2 joyAxis;
void Start () {
joyAxis = GameObject.Find("Joystick").GetComponent<Joystick>()._axis;
}
Error: the type or namespace name `Joystick' could not be found.
The class is correctly spelled.
I also checked the "Joystick"-gameObject to make sure the Joystick-Script is assigned.
Are you sure Joystick (the script) is spelled correctly? Remember, scripts are case-sensitive.
Well, I have used this script here and it's called the same. I also changed the Vector2 to public.
Answer by Hellium · Aug 11, 2015 at 09:36 AM
Could you tell us what are the first lines of the Joystick script ?
You may not have included the namespace in the CharacterMovement script ...
Answer by nullgobz · Aug 10, 2015 at 08:47 PM
Make sure the joystick script has a class called "Joystick" As RLin commented it has to be the same caseing.
Error means that "GetComponent()" cant find a class called "Joystick" in the project.
Your answer
![](https://koobas.hobune.stream/wayback/20220611235239im_/https://answers.unity.com/themes/thub/images/avi.jpg)