Skip to content

Instantly share code, notes, and snippets.

@ArturoNereu
Created April 16, 2016 04:30
Show Gist options
  • Save ArturoNereu/9beccc85599f800ce05349f89d141684 to your computer and use it in GitHub Desktop.
Save ArturoNereu/9beccc85599f800ce05349f89d141684 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class TankNetworkConfigurator : NetworkBehaviour
{
public bool runsStandalone = true;
[SyncVar]
public Color RenderersColor;
protected void OnColorSet(Color colorToSet)
{
MeshRenderer[] renderers = transform.GetComponentsInChildren<MeshRenderer>();
for (int i = 0; i < renderers.Length; i++)
{
renderers[i].material.color = colorToSet;
}
}
void Start()
{
if(runsStandalone)
SetUpCamera ();
OnColorSet (RenderersColor);
}
private void SetUpCamera()
{
CameraControl cameraControl = (CameraControl)FindObjectOfType (typeof(CameraControl));
GameObject[] gameTanks = GameObject.FindGameObjectsWithTag ("Player");
Transform[] targets = new Transform[gameTanks.Length];
for (int i = 0; i < targets.Length; i++)
{
targets[i] = gameTanks[i].transform;
}
cameraControl.m_Targets = targets;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment