ScriptA:
public GameObject Player1;
public Player player;
void Start(){
Player1 = GameObject.FindWithTag(“Player1”);
player = Player1.GetComponent();
ScriptB.player = player;
}
ScriptB:
public Player player;
ScriptA:
public GameObject Player1;
public Player player;
void Start(){
Player1 = GameObject.FindWithTag(“Player1”);
player = Player1.GetComponent();
ScriptB.player = player;
}
ScriptB:
public Player player;
I honestly have no idea what you’re asking. Yes, any public instance variable can be set from another script given you have a reference to an instance of that other script. You should be able to set player in ScriptB from ScriptA.
Yes you can, but you need a reference to Script B.
For example:
GameObject.FindWithTag(“GameObjectWhereScriptBIsAttached”).GetComponent().player = player;
What @Varhius said. Additionally, here’s a handy list of ways you can get references to other objects!