Cambob script
public function DoSomething ()
{
Debug.Log ( "You should be doing something...");
}
Script that calls the function
// this variable will show up in the inspector
// place the GameObject that has the Cambob script attached to it inside the variables' field
public var bobScript : Cambob;
function Update ()
{
bobScript.DoSomething ();
}
You can also reference the Cambob script through code so you don't have to use the editor,
but this method is slower.
// I made it private because there is no need to use/change it inside of the editor
// (unless you want to check if the correct GameObject appears when executed).
private var bobScript : Cambob;
function Awake ()
{
bobScript = GameObject.Find ( "The GameObject Name" ).GetComponent ( Cambob );
}
function Update ()
{
bobScript.DoSomething ();
}
↧