I get this:
Assets/pausemenu.cs(31,26): error CS0176: Static member `pausebutton.clickedpause’ cannot be accessed with an instance reference, qualify it with a type name instead
here’s a snippet of my code:
public GameObject pausecomp;
public pausebutton menuM; // script
// Use this for initialization
void Start(){
pausecomp = GameObject.Find("pause");
menuM = pausecomp.GetComponent<pausebutton>();
}
void Update () {
if(menuM.clickedpause = false){
print("hello");
}
Well, I missed read your post. You wan to access a variable from other game object not a variable in the same game object. For example, the isWalking is declared in the OtherScript as the following:
//OtherScript.js
var isWalking: bool = false;
function Start()
{
isWalking = true;
}
function Update()
{
/*
if (Input.GetKeyDown ("w"))
{
isWalking = true;
}
*/
}
in your current game object, you can access the isWalking as the following:
var other : OtherScript = FindObjectOfType(OtherScript);
print(other.IsWalking);
hm… is there any reason why even when I have the static variable in my other script set to false, the variable passes as true in the script that finds the other variable? (sorry if that’s a bit confusing lol)
I have a pause button at the top left of the window and when I click it, I want a little menu to drop down.
the problem is that the drop down menu is one game object and the pause button is another.
…tried it but doesn’t change the boolean to what I set it to =/
If there is only one pause button in the game the script should only be on one GameObject.
Then you can look at it with:
pausebutton.clickedpause
If its not being set correctly, or displayed correctly, or printed to the console correctly, thats just a bug you will have to find or post code.
When debugging its easy to make different mistakes that you dont see until the main problem is fixed.
For some reason my script won’t access other scripts in the same project.
I.e. I have two scripts: Script1 and Script2.
In Script1 I cannot call Script2.variable
Anyone know why?