using UnityEngine; [ExecuteAlways] public class Node : MonoBehaviour { [Range(-1, 1)] [SerializeField] private int Owner = -1; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { } // Update is called once per frame void Update() { transform.localPosition = transform.localPosition.normalized * 20f; transform.forward = transform.position; switch (Owner) { case 0: transform.GetChild(0).GetComponent().sharedMaterial.color = Color.red; break; case 1: transform.GetChild(0).GetComponent().sharedMaterial.color = Color.green; break; case -1: transform.GetChild(0).GetComponent().sharedMaterial.color = Color.gray; break; } } }