Make one script run another script

Hi all

I would like to set-up a C Sharp script that checks the scene for certain objects and executes other scripts depending on what it has found

void Start () {
	
        if (GameObject.Find("Cat") != null)
	{
		//RUN CAT SCRIPT
	}

        else
	{
		//RUN DOG SCRIPT
	}
}

I have no idea what code is used to execute a certain script on request.

Any help will be appreciated.

Thanks!

http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

You don’t really “execute scripts” though, you call functions in a script.

–Eric

The approach I use is the generic GetComponent method.

var goCat = GameObject.Find("Cat");
if( goCat != null )
{
    goCat.GetComponent<YourCatScript>().YourCatMethod();
}

Thanks!