Here is my situation:
I have a private variable that contains a Monobehaviour.
When the connection is established, this script is found.
When an RPC is called in which I want to use this script on a client(not for the server!), it returns NULL?!
The script is not being destroyed nor being set to NULL anywhere in my game.
public override void OnStartLocalPlayer () {
builderScript = GameObject.Find ("Terrain").GetComponent<TowerBuilder> ();
Debug.Log (builderScript);//this works
}
[ClientRpc]
void RpcBuildTower(Vector3 buildPos, Quaternion buildRot, Color towerC){
Debug.Log (builderScript);//prints "NULL"
builderScript = GameMaster.instance.builderScript;//I have to find it again to get it working
Debug.Log (builderScript);//prints "TowerBuilder" again
builderScript.BuildTower (buildPos, buildRot, towerC);
}
Any help is appreciated!