Can I attach the Main Camera to two scripts?

I have objects Main Camera and Player Ship. Player Ship has a script attached (Ship.js) with a var myCamera : Camera (Main Camera is assigned).

Now I’ve created another script HitPointBarController.js, also with a var myCamera : Camera, but the Inspector won’t let me assign Main Camera to it.

What’s up with that? Am I missing something?

A another way is to search for the tag of camera on function Start.
Here’s an example:

var myCamera : Camera;

function Start(){
     myCamera =  GameObject.FindGameObjectWithTag("MainCamera");
}

Hope it helped :slight_smile: