Please help!
I have a Javascript component that references 2 game objects. The problem is, the game objects don't exist at start up and only instantiate when the player joins a network room. The network manager script is in C#.
I need to update the JS script from the C# script when the player is instantiated.
The code I have so far...
SpawnSpot mySpawnSpot = spawnSpots [Random.Range (0, spawnSpots.Length)];
GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate ("PlayerSHIP", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
standbyCamera.SetActive (false);
((MonoBehaviour)myPlayerGO.GetComponent ("PlayerControl")).enabled = true;
((MonoBehaviour)myPlayerGO.GetComponent ("PlayerShooting")).enabled = true;
myPlayerGO.transform.FindChild ("CameraCP").gameObject.SetActive (true);
myPlayerGO.transform.FindChild ("LocalShip").gameObject.SetActive (true);
myPlayerGO.transform.FindChild ("RemoteShip").gameObject.SetActive (false);
GameObject test = GameObject.Find ("RadarMgr");
Component test2 = test.GetComponent("3DRadar");
test2.Transforms[0] = "LocalShip";
//test.GetComponent("Radar_Mgr").Transforms[0] = "LocalShip";
This is the network C# script. The JS script I'm wanting to access, is the "3DRadar" component which is part of the "RadarMgr" game object. The "Transforms[0]" is the part of the JS script that holds the game object needed and "LocalShip" is the game object I'm trying to tell the JS script to use. The last 2 lines are my failed attempts at assigning the LocalShip to the JS script. I did have other syntax instead of those 2 lines, but nothing has worked and that is just how it got left.
The other object needed would be the "CameraCP" object, but obviously if I could sort out how to do 1, the other would be done the same way.
I have searched for the last 3 days on here, unity answers and general google, but if the answer is out there somewhere, I cannot find it nor understand it.
I hope someone can shed some light on this frustrating hurdle!
Thanks!