Created
April 16, 2016 04:30
-
-
Save ArturoNereu/9beccc85599f800ce05349f89d141684 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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