calling functions from any script ?

I’m having trouble calling a function from any script I want. It seems like everything in the script that’s going to be called must be set to a static. I’m very confused I cant just call a function from a different script and then have it call another function inside of that other script. Any easy way of doing this ?

Nothing has to be set to static, and shouldn’t be unless that’s what you actually want (which it frequently isn’t). See the docs about accessing other game objects.

OtherScriptClass otherscript = transform.GetComponent();

easy as that… though in order for it to work, you need OtherScriptClass assigned to the gameObject as a component.

Now, since you didn’t say what language you’re using I’m going to assume that you use what I use (C#). If you’re using Javascript or Boo, then consult the unity refs and figure out how to make it work with your language (it’s pretty easy).

You mentioned making something static- that’s only for something that is not going to change during runtime (hence static). You can assign a script reference to a static variable and make it accessable to any script at any time- but it’s only useful for things that are singular in nature (such as a camera controller, or gamestate manager, something like that).

In those cases, yes- you would use the static keyword and make it a publicly accessable member variable like this:

class MyClass : MonoBehaviour    
	public static MyClass Instance;    

	void Awake()    
		Instance = this; // you can now call MyClass.Instance.Function() from anywhere in any script	    

	public void Function()    
		Debug.Log("Hey, it works");