i am a beginner in unity and c#, as well as oop, i am since two days to study for this proble but i cannot find the solution, and das problem: there is a class which has just start and update:using UnityEngine;
using System.Collections;
public class White : MonoBehaviour {
public float duration = 1.0F;
public Light lt;
void Start() {
lt = GetComponent();
}
void Update() {
if(Input.GetKeyDown(KeyCode.W)) {
float phi = Time.time / duration * 2 * Mathf.PI;
float amplitude = Mathf.Cos(phi) * 3F + 3F;
lt.intensity = amplitude;}}}
i need to call this funtion, which is for adjusting the light in another class, with a if statment such as:
public White whitelight;//there is in this script too
//if the ray cast, then call the function light adjusting , i must stop here?
if (Physics.Raycast (ray, out hits, 100f)) {
if (hits.collider.tag == "Light") {
//Debug.Log ("Raycast hit a light");
????????
how i can call this function, because the first script has just state and update method, i dont know, how ? or must i write the code again under if statment?
Thank you very much for your response, please note i ma absolute beginner, if you want to answer for beginner please, thank you again.