One GameObjects Script Activating Another GameObjects Script

I’m very new to Unity and I will say it is an amazing engine. But for some time now, I’ve had this dilemma of witch I have no idea how to fix or do, and that’s activating and GameObject to effect another. I have looked around and used codes like…

(For Java Scripts)

otherObject.GetComponent(NameOfScript).enabled = true;

But seem to get no were, if it is possible, could someone show me the right way to do these sorts of codes in a little script example.

My situation is this, this is on a main menu and there’s is a button and a camera. Lets say when I click the button (named “NewGame”), it goes to a new scene, but before that, I want a little animation of the camera(Named “Maincamera”) moving in. There’s already a script attached to the camera(script named “cameramove”) that when activated, plays the animation.
How would the script for the button look like if it activates the camera script.


well you first want to put everything in a varible, the way your going about it, may work like this

var objectB : GameObject;
var objectBScript;

function Awake(){
   objectB = GameObject.FindWithTag("objectB");
objectBScript = objectB.GetComponent(superscript);
function TurnOnScript(){
  objectBScript.enabled = true;

Another way you could handle it would be to just use a boolean as a switch in object B so

on Object be

var Off : boolean = true;
function Update(){

if (Off)
//this line would not run till off is turn off.
function TurnOffOff(){
Off = false;

then in object A you would have a script like

var objectB : GameObject;

function Awake()
objectB = GameObject.FindWithTag("objectB");
function turnOffOFf(){
//sends a message to object B to run the turnoffoff function