private void Update() { bool hasHit = Physics.Raycast(transform.position, transform.forward, out RaycastHit hit, Mathf.Infinity); if (hasHit) { SunlightBar sunlightBar = hit.transform.GetComponent <SunlightBar>(); if (sunlightBar) { sunlightBar.GainLight(); } } }
private void Awake() { bar = GameObject.FindWithTag("Player").GetComponent <SunlightBar>(); text = GetComponent <Text>(); }