danny7
1
Here’s my script:
#pragma strict
var otherPlayers : GameObject[];
@RPC
function MultiplayerControlsDisablation ()
{
var otherCameras : Component[] = otherPlayers.GetComponentsInChildren.<Camera>();
for (var c : Camera in otherCameras)
{
(c.GetComponentsInChildren(Camera) as MonoBehaviour).enabled = false;
}
}
I want to disable the other cameras in the scene from other networked players.
I get the error:
BCE0019: 'GetComponentsInChildren' is not a member of 'UnityEngine.GameObject[]'.
What should I do?
Try this:
for(var player : GameObject in otherPlayers)
{
var playerCamera : Camera = player.GetComponentInChildren.<Camera>();
playerCamera.enabled = false;
}
You can also disable the game objects by swapping playerCamera.enabled = false; to
c.gameObject.SetActive(false);
Hope this helps. 